diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-08 16:19:58 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2010-10-08 16:19:58 +0000 |
commit | df42830468062375c73edb7cc16e7919f555837e (patch) | |
tree | a581322c1c0e8cf1ccdcd6eb771a9d4aeefa1dfd /ext/standard | |
parent | 74ec58a045434d5a9938d187a51b1f87c7b8ef8a (diff) | |
download | php-git-df42830468062375c73edb7cc16e7919f555837e.tar.gz |
- Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities with ENT_NOQUOTES and ISO-8859-1).
Diffstat (limited to 'ext/standard')
-rw-r--r-- | ext/standard/html.c | 13 | ||||
-rw-r--r-- | ext/standard/tests/strings/bug53021.phpt | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/ext/standard/html.c b/ext/standard/html.c index f937e1dd3b..900cb3910f 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -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 index 0000000000..6f290096e4 --- /dev/null +++ b/ext/standard/tests/strings/bug53021.phpt @@ -0,0 +1,10 @@ +--TEST--
+Bug #53021 (Failure to convert numeric entities with ENT_NOQUOTES and ISO-8859-1)
+--FILE--
+<?php
+var_dump(unpack("H*",html_entity_decode("é", ENT_QUOTES, "ISO-8859-1")));
+--EXPECT--
+array(1) {
+ [1]=>
+ string(2) "e9"
+}
|