1--TEST--
2html_entity_decode: Decoding of entities after invalid entities
3--FILE--
4<?php
5$arr = array(
6    "&",
7    "&&amp;",
8    "&&#x24;",
9    "&#&amp;",
10    "&#&#x24;",
11    "&#x&amp;",
12    "&#x&#x24;",
13    "&#x1&amp;",
14    "&#x1&#x24;",
15    "&#x20&amp;",
16    "&#x20&#x24;",
17    "&#1&amp;",
18    "&#1&#x24;",
19    "&#20&amp;",
20    "&#20&#x24;",
21    "&a&amp;",
22    "&a&#x24;",
23    "&aa&amp;",
24    "&aa&#x24;",
25    "&aa;&amp;",
26    "&aa;&#x24;",
27    "&;&amp;",
28    "&;&#x24;",
29);
30
31$i = 0;
32foreach ($arr as $ent) {
33    if ($i % 2 == 1) {
34        if (($a = html_entity_decode($ent, ENT_QUOTES, 'UTF-8')) !=
35                ($b = htmlspecialchars_decode($ent, ENT_QUOTES))) {
36            echo "htmlspecialchars_decode <-> html_entity_decode inconsistency","\n",
37                 "$b <-> $a","\n";
38        }
39    }
40    echo html_entity_decode($ent, ENT_QUOTES, 'UTF-8'), "\n";
41}
42echo "Done.\n";
43?>
44--EXPECT--
45&
46&&
47&$
48&#&
49&#$
50&#x&
51&#x$
52&#x1&
53&#x1$
54&#x20&
55&#x20$
56&#1&
57&#1$
58&#20&
59&#20$
60&a&
61&a$
62&aa&
63&aa$
64&aa;&
65&aa;$
66&;&
67&;$
68Done.
69