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
24
24
- [ #45 ] ( https://github.com/zendframework/zend-mail/pull/45 ) ensures that the
25
25
message parser allows deserializing message bodies containing multiple EOL
26
26
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 ) ).
27
32
28
33
## 2.6.1 - 2016-02-24
29
34
Original file line number Diff line number Diff line change @@ -116,7 +116,21 @@ public static function mimeDecodeValue($value)
116
116
*/
117
117
public static function canBeEncoded ($ value )
118
118
{
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 );
120
134
121
135
return (false !== $ encoded );
122
136
}
Original file line number Diff line number Diff line change 9
9
10
10
namespace ZendTest \Mail \Header ;
11
11
12
+ use Zend \Mail \Header \GenericHeader ;
12
13
use Zend \Mail \Header \HeaderWrap ;
13
14
14
15
/**
@@ -71,4 +72,24 @@ public function testMimeDecoding()
71
72
72
73
$ this ->assertEquals ($ expected , $ decoded );
73
74
}
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
+ }
74
95
}
You can’t perform that action at this time.
0 commit comments