This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ All notable changes to this project will be documented in this file, in reverse
2424- [ #45 ] ( https://github.com/zendframework/zend-mail/pull/45 ) ensures that the
2525 message parser allows deserializing message bodies containing multiple EOL
2626 sequences.
27+ - [ #78 ] ( https://github.com/zendframework/zend-mail/pull/78 ) fixes the logic of
28+ ` HeaderWrap::canBeEncoded() ` to ensure it returns correctly for header lines
29+ containing at least one multibyte character, and particularly when that
30+ character falls at specific locations (per a
31+ [ reported bug at php.net] ( https://bugs.php.net/bug.php?id=53891 ) ).
2732
2833## 2.6.1 - 2016-02-24
2934
Original file line number Diff line number Diff line change @@ -116,7 +116,21 @@ public static function mimeDecodeValue($value)
116116 */
117117 public static function canBeEncoded ($ value )
118118 {
119- $ encoded = iconv_mime_encode ('x-test ' , $ value , ['scheme ' => 'Q ' ]);
119+ // avoid any wrapping by specifying line length long enough
120+ // "test" -> 4
121+ // "x-test: =?ISO-8859-1?B?dGVzdA==?=" -> 33
122+ // 8 +2 +3 +3 -> 16
123+ $ charset = 'UTF-8 ' ;
124+ $ lineLength = strlen ($ value ) * 4 + strlen ($ charset ) + 16 ;
125+
126+ $ preferences = [
127+ 'scheme ' => 'Q ' ,
128+ 'input-charset ' => $ charset ,
129+ 'output-charset ' => $ charset ,
130+ 'line-length ' => $ lineLength ,
131+ ];
132+
133+ $ encoded = iconv_mime_encode ('x-test ' , $ value , $ preferences );
120134
121135 return (false !== $ encoded );
122136 }
Original file line number Diff line number Diff line change 99
1010namespace ZendTest \Mail \Header ;
1111
12+ use Zend \Mail \Header \GenericHeader ;
1213use Zend \Mail \Header \HeaderWrap ;
1314
1415/**
@@ -71,4 +72,24 @@ public function testMimeDecoding()
7172
7273 $ this ->assertEquals ($ expected , $ decoded );
7374 }
75+
76+ /**
77+ * Test that fails with HeaderWrap::canBeEncoded at lowest level:
78+ * iconv_mime_encode(): Unknown error (7)
79+ *
80+ * which can be triggered as:
81+ * $header = new GenericHeader($name, $value);
82+ */
83+ public function testCanBeEncoded ()
84+ {
85+ $ name = 'Subject ' ;
86+ $ value = "[#77675] New Issue:xxxxxxxxx xxxxxxx xxxxxxxx xxxxxxxxxxxxx xxxxxxxxxx xxxxxxxx, tähtaeg xx.xx, xxxx " ;
87+ $ encoded = "Subject: =?UTF-8?Q?[#77675]=20New=20Issue:xxxxxxxxx=20xxxxxxx=20xxxxxxxx=20?= \r\n =?UTF-8?Q?xxxxxxxxxxxxx=20xxxxxxxxxx=20xxxxxxxx,=20t=C3=A4htaeg=20xx.xx,=20xxxx?= " ;
88+ $ res = HeaderWrap::canBeEncoded ($ value );
89+ $ this ->assertTrue ($ res );
90+
91+ $ header = new GenericHeader ($ name , $ value );
92+ $ res = $ header ->toString ();
93+ $ this ->assertEquals ($ encoded , $ res );
94+ }
7495}
You can’t perform that action at this time.
0 commit comments