xref: /PHP-8.0/ext/iconv/tests/bug52941.phpt (revision 953b10c5)
1--TEST--
2Bug #52941 (The 'iconv_mime_decode_headers' function is skipping headers)
3--SKIPIF--
4<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
5--FILE--
6<?php
7$headers = <<<HEADERS
8From: =?UTF-8?B?PGZvb0BleGFtcGxlLmNvbT4=?=
9Subject: =?ks_c_5601-1987?B?UkU6odk=?=
10X-Foo: =?ks_c_5601-1987?B?UkU6odk=?= Foo
11X-Bar: =?ks_c_5601-1987?B?UkU6odk=?= =?UTF-8?Q?Foo?=
12To: <test@example.com>
13HEADERS;
14
15$decoded = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8');
16
17var_dump($decoded['From']);
18var_dump($decoded['Subject']);
19var_dump($decoded['X-Foo']);
20var_dump($decoded['X-Bar']);
21var_dump($decoded['To']);
22
23$decoded = iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR | ICONV_MIME_DECODE_STRICT, 'UTF-8');
24
25var_dump($decoded['From']);
26var_dump($decoded['Subject']);
27var_dump($decoded['X-Foo']);
28var_dump($decoded['X-Bar']);
29var_dump($decoded['To']);
30?>
31--EXPECTF--
32string(17) "<foo@example.com>"
33string(%d) "%s"
34string(%d) "%sFoo"
35string(%d) "%sFoo"
36string(18) "<test@example.com>"
37string(17) "<foo@example.com>"
38string(%d) "%s"
39string(%d) "%sFoo"
40string(%d) "%sFoo"
41string(18) "<test@example.com>"
42