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--EXPECT--
44&
45&&
46&$
47&#&
48&#$
49&#x&
50&#x$
51&#x1&
52&#x1$
53&#x20&
54&#x20$
55&#1&
56&#1$
57&#20&
58&#20$
59&a&
60&a$
61&aa&
62&aa$
63&aa;&
64&aa;$
65&;&
66&;$
67Done.
68