Skip to content

Commit 907d0c3

Browse files
committed
Add more tests for UTF7-IMAP text conversion
1 parent bf940a1 commit 907d0c3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ext/mbstring/tests/utf7imap_encoding.phpt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,24 +110,30 @@ if (strlen($testString) != 4)
110110
$testString = substr($testString, 2, 2) . substr($testString, 0, 2);
111111
identifyInvalidString("&" . mBase64($testString) . "-", 'UTF7-IMAP');
112112
/* (Or could appear by itself) */
113-
$testString = substr($testString, 0, 2);
114-
identifyInvalidString("&" . mBase64($testString) . "-", 'UTF7-IMAP');
113+
$testString2 = substr($testString, 0, 2);
114+
identifyInvalidString("&" . mBase64($testString2) . "-", 'UTF7-IMAP');
115115

116116
/* ...and we should detect this wherever it occurs */
117-
$singleChar = mb_convert_encoding("", 'UTF-16BE', 'ASCII');
117+
$singleChar = "\x00\x01";
118118
$doubleChar = mb_convert_encoding("\x00\x01\x04\x01", 'UTF-16BE', 'UTF-32BE');
119119
if (strlen($doubleChar) != 4)
120120
die("That was supposed to be a surrogate pair");
121121
identifyInvalidString("&" . mBase64($singleChar . $testString) . "-", 'UTF7-IMAP');
122122
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $testString) . "-", 'UTF7-IMAP');
123123
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $singleChar . $testString) . "-", 'UTF7-IMAP');
124+
identifyInvalidString("&" . mBase64($singleChar . $testString2) . "-", 'UTF7-IMAP');
125+
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $testString2) . "-", 'UTF7-IMAP');
126+
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $singleChar . $testString2) . "-", 'UTF7-IMAP');
124127
identifyInvalidString("&" . mBase64($doubleChar . $testString) . "-", 'UTF7-IMAP');
125128
identifyInvalidString("&" . mBase64($singleChar . $doubleChar . $testString) . "-", 'UTF7-IMAP');
126129
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $doubleChar . $testString) . "-", 'UTF7-IMAP');
130+
identifyInvalidString("&" . mBase64($doubleChar . $testString2) . "-", 'UTF7-IMAP');
131+
identifyInvalidString("&" . mBase64($singleChar . $doubleChar . $testString2) . "-", 'UTF7-IMAP');
132+
identifyInvalidString("&" . mBase64($singleChar . $singleChar . $doubleChar . $testString2) . "-", 'UTF7-IMAP');
127133

128134
/* 2. The first half of a surrogate pair might be followed by an invalid 2nd part, */
129135
$testString = mb_convert_encoding("\x00\x01\x04\x00", 'UTF-16BE', 'UTF-32BE');
130-
$testString = substr($testString, 0, 2) . mb_convert_encoding("a", 'UTF-16BE', 'ASCII');
136+
$testString = substr($testString, 0, 2) . "\x00a";
131137
identifyInvalidString("&" . mBase64($testString) . "-", 'UTF7-IMAP');
132138

133139
/* ...and we should also detect that wherever it occurs... */

0 commit comments

Comments
 (0)