Bug111Test.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. require_once 'Swift/Tests/SwiftUnitTestCase.php';
  3. class Swift_Bug111Test extends Swift_Tests_SwiftUnitTestCase
  4. {
  5. public function testUnstructuredHeaderSlashesShouldNotBeEscaped()
  6. {
  7. $complicated_header = array(
  8. 'to'=> array(
  9. 'email1@example.com',
  10. 'email2@example.com',
  11. 'email3@example.com',
  12. 'email4@example.com',
  13. 'email5@example.com',
  14. ),
  15. 'sub' => array(
  16. '-name-' => array(
  17. 'email1',
  18. '"email2"',
  19. 'email3\\',
  20. 'email4',
  21. 'email5',
  22. ),
  23. '-url-' => array(
  24. 'http://google.com',
  25. 'http://yahoo.com',
  26. 'http://hotmail.com',
  27. 'http://aol.com',
  28. 'http://facebook.com',
  29. ),
  30. )
  31. );
  32. $json = json_encode($complicated_header);
  33. $message = new Swift_Message();
  34. $headers = $message->getHeaders();
  35. $headers->addTextHeader('X-SMTPAPI', $json);
  36. $header = $headers->get('X-SMTPAPI');
  37. $this->assertEqual('Swift_Mime_Headers_UnstructuredHeader', get_class($header));
  38. $this->assertEqual($json, $header->getFieldBody());
  39. }
  40. }