From efc94f311593d33093b8ad7f1f036deaa23df052 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gustavo=20Andr=C3=A9=20dos=20Santos=20Lopes?= Date: Tue, 13 Mar 2012 18:08:30 +0000 Subject: [PATCH] - Fixed bug #61374: html_entity_decode tries to decode code points that don't exist in ISO-8859-1. --- ext/standard/html.c | 5 +++-- ext/standard/tests/strings/bug61374.phpt | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 ext/standard/tests/strings/bug61374.phpt diff --git a/ext/standard/html.c b/ext/standard/html.c index d95be5d197..65e63f41cc 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1004,8 +1004,9 @@ static void traverse_for_entities( /* && code2 == '\0' always true for current maps */) goto invalid_code; - /* deal with encodings other than utf-8/iso-8859-1 */ - if (!CHARSET_UNICODE_COMPAT(charset)) { + /* UTF-8 doesn't need mapping (ISO-8859-1 doesn't either, but + * the call is needed to ensure the codepoint <= U+00FF) */ + if (charset != cs_utf_8) { /* replace unicode code point */ if (map_from_unicode(code, charset, &code) == FAILURE || code2 != 0) goto invalid_code; /* not representable in target charset */ diff --git a/ext/standard/tests/strings/bug61374.phpt b/ext/standard/tests/strings/bug61374.phpt new file mode 100644 index 0000000000..b7fce11ee2 --- /dev/null +++ b/ext/standard/tests/strings/bug61374.phpt @@ -0,0 +1,7 @@ +--TEST-- +Bug #61374: html_entity_decode tries to decode code points that don't exist in ISO-8859-1 +--FILE-- +