Browse Source

ZF-10074: Zend_Mime: Fix issue with quoted-printable encoding of lines ending in zero

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24797 44c647ce-9c0f-0410-b52a-842ac1e357ba
adamlundrigan 13 years ago
parent
commit
68145992a9
2 changed files with 12 additions and 1 deletions
  1. 1 1
      library/Zend/Mime.php
  2. 11 0
      tests/Zend/MimeTest.php

+ 1 - 1
library/Zend/Mime.php

@@ -130,7 +130,7 @@ class Zend_Mime
         $str = self::_encodeQuotedPrintable($str);
 
         // Split encoded text into separate lines
-        while ($str) {
+        while(strlen($str) > 0) {
             $ptr = strlen($str);
             if ($ptr > $lineLength) {
                 $ptr = $lineLength;

+ 11 - 0
tests/Zend/MimeTest.php

@@ -73,6 +73,17 @@ class Zend_MimeTest extends PHPUnit_Framework_TestCase
         $this->assertEquals(quoted_printable_decode($qp), $text);
     }
 
+    /**
+     * @group ZF-10074
+     */
+    public function testEncodeQuotedPrintableWhenTextHasZeroAtTheEnd()
+    {
+        $raw = str_repeat('x',72) . '0';
+        $quoted = Zend_Mime::encodeQuotedPrintable($raw, 72);
+        $expected = quoted_printable_decode($quoted);        
+        $this->assertEquals($expected, $raw);
+    }
+
     public function testBase64()
     {
         $content = str_repeat("\x88\xAA\xAF\xBF\x29\x88\xAA\xAF\xBF\x29\x88\xAA\xAF", 4);