summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/html_entity_decode1.phpt
blob: 8d7a07784e0dd990d81ae076881dbdfe610749bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--TEST--
html_entity_decode: Decoding of entities after invalid entities
--FILE--
<?php
$arr = array(
    "&",
    "&&amp;",
    "&&#x24;",
    "&#&amp;",
    "&#&#x24;",
    "&#x&amp;",
    "&#x&#x24;",
    "&#x1&amp;",
    "&#x1&#x24;",
    "&#x20&amp;",
    "&#x20&#x24;",
    "&#1&amp;",
    "&#1&#x24;",
    "&#20&amp;",
    "&#20&#x24;",
    "&a&amp;",
    "&a&#x24;",
    "&aa&amp;",
    "&aa&#x24;",
    "&aa;&amp;",
    "&aa;&#x24;",
    "&;&amp;",
    "&;&#x24;",
);

$i = 0;
foreach ($arr as $ent) {
    if ($i % 2 == 1) {
        if (($a = html_entity_decode($ent, ENT_QUOTES, 'UTF-8')) !=
                ($b = htmlspecialchars_decode($ent, ENT_QUOTES))) {
            echo "htmlspecialchars_decode <-> html_entity_decode inconsistency","\n",
                 "$b <-> $a","\n";
        }
    }
    echo html_entity_decode($ent, ENT_QUOTES, 'UTF-8'), "\n";
}
echo "Done.\n";
--EXPECT--
&
&&
&$
&#&
&#$
&#x&
&#x$
&#x1&
&#x1$
&#x20&
&#x20$
&#1&
&#1$
&#20&
&#20$
&a&
&a$
&aa&
&aa$
&aa;&
&aa;$
&;&
&;$
Done.