Browse Source

Fix ZF-10792: Encode comma in from/to/cc display name. Patch by Christoph Roensch.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24953 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob 13 years ago
parent
commit
39a9b2cec7
2 changed files with 22 additions and 1 deletions
  1. 1 1
      library/Zend/Mime.php
  2. 21 0
      tests/Zend/Mail/MailTest.php

+ 1 - 1
library/Zend/Mime.php

@@ -194,7 +194,7 @@ class Zend_Mime
         $str = self::_encodeQuotedPrintable($str);
 
         // Mail-Header required chars have to be encoded also:
-        $str = str_replace(array('?', ' ', '_'), array('=3F', '=20', '=5F'), $str);
+        $str = str_replace(array('?', ' ', '_', ','), array('=3F', '=20', '=5F', '=2C'), $str);
 
         // initialize first line, we need it anyways
         $lines = array(0 => "");

+ 21 - 0
tests/Zend/Mail/MailTest.php

@@ -638,6 +638,27 @@ class Zend_Mail_MailTest extends PHPUnit_Framework_TestCase
         $this->assertContains("\r\n\r\n...after", $body, $body);
     }
 
+    public function testZf10792CommaInRecipientNameIsEncodedProperly()
+    {
+        $mail = new Zend_Mail("UTF-8");
+        $mail->setFrom('from@email.com', 'Doe, John');
+        $mail->addTo('to@email.com', 'Döe, Jöhn');
+        $mail->setBodyText('my body');
+
+        $mock = new Zend_Mail_Transport_Mock();
+        $mail->send($mock);
+
+        $this->assertContains(
+            'From: "Doe, John" <from@email.com>',
+            $mock->header
+        );
+
+        $this->assertContains(
+            'To: =?UTF-8?Q?D=C3=B6e=2C=20J=C3=B6hn?= <to@email.com>',
+            $mock->header
+        );
+    }
+
     public function testGetJustBodyText()
     {
         $text = "my body\r\n\r\n...after two newlines";