]> granicus.if.org Git - php/commitdiff
- Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities with...
authorGustavo André dos Santos Lopes <cataphract@php.net>
Fri, 8 Oct 2010 16:19:58 +0000 (16:19 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Fri, 8 Oct 2010 16:19:58 +0000 (16:19 +0000)
ext/standard/html.c
ext/standard/tests/strings/bug53021.phpt [new file with mode: 0644]

index f937e1dd3b5d36f09f55fab18ec10f4297aee1a8..900cb3910f221bb43960b861098d470ffa89df10 100644 (file)
@@ -1020,7 +1020,12 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
                                                code = strtol(p + 2, &next, 10);
                                        }
 
-                                       if (next != NULL && *next == ';') {
+                                       if (code == 39 && !(quote_style & ENT_HTML_QUOTE_SINGLE) ||
+                                               code == 24 && !(quote_style & ENT_HTML_QUOTE_DOUBLE)) {
+                                               invalid_code = 1;
+                                       }
+
+                                       if (next != NULL && *next == ';' && !invalid_code) {
                                                switch (charset) {
                                                        case cs_utf_8:
                                                                q += php_utf32_utf8(q, code);
@@ -1032,11 +1037,7 @@ PHPAPI char *php_unescape_html_entities(unsigned char *old, int oldlen, int *new
                                                                if ((code >= 0x80 && code < 0xa0) || code > 0xff) {
                                                                        invalid_code = 1;
                                                                } else {
-                                                                       if (code == 39 || !quote_style) {
-                                                                               invalid_code = 1;
-                                                                       } else {
-                                                                               *(q++) = code;
-                                                                       }
+                                                                       *(q++) = code;
                                                                }
                                                                break;
 
diff --git a/ext/standard/tests/strings/bug53021.phpt b/ext/standard/tests/strings/bug53021.phpt
new file mode 100644 (file)
index 0000000..6f29009
--- /dev/null
@@ -0,0 +1,10 @@
+--TEST--\r
+Bug #53021 (Failure to convert numeric entities with ENT_NOQUOTES and ISO-8859-1)\r
+--FILE--\r
+<?php\r
+var_dump(unpack("H*",html_entity_decode("&#233;", ENT_QUOTES, "ISO-8859-1")));\r
+--EXPECT--\r
+array(1) {\r
+  [1]=>\r
+  string(2) "e9"\r
+}\r