xref: /PHP-7.3/ext/iconv/tests/bug51250.phpt (revision d506ce8d)
1--TEST--
2Bug #51250 (iconv_mime_decode() does not ignore malformed Q-encoded words)
3--SKIPIF--
4<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
5--FILE--
6<?php
7$m = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
8
9var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?B?Kg==?= .", $m));
10var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?Q?*?= .", $m));
11var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?B?".chr(0xA1)."?= .", $m));
12var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?Q?".chr(0xA1)."?= .", $m));
13
14var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?B?Kg==?= ."));
15var_dump(iconv_mime_decode("Legal encoded-word: =?utf-8?Q?*?= ."));
16var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?B?".chr(0xA1)."?= ."));
17var_dump(iconv_mime_decode("Illegal encoded-word: =?utf-8?Q?".chr(0xA1)."?= ."));
18?>
19--EXPECTF--
20string(23) "Legal encoded-word: * ."
21string(23) "Legal encoded-word: * ."
22string(24) "Illegal encoded-word:  ."
23string(23) "Illegal encoded-word: ."
24string(23) "Legal encoded-word: * ."
25string(23) "Legal encoded-word: * ."
26string(24) "Illegal encoded-word:  ."
27
28Notice: iconv_mime_decode(): Detected an illegal character in input string in %s on line %d
29bool(false)
30