- Fixed bug #61374: html_entity_decode tries to decode code points that don't
authorGustavo André dos Santos Lopes <cataphract@php.net>
Tue, 13 Mar 2012 18:08:30 +0000 (18:08 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Tue, 13 Mar 2012 18:08:30 +0000 (18:08 +0000)
  exist in ISO-8859-1.

NEWS
ext/standard/html.c
ext/standard/tests/strings/bug61374.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 4414a010723d7d63c6b46cfdf310b1b4efc2c141..873ed048734df8c59d503af5d4c006b3c128cda5 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,8 @@ PHP                                                                        NEWS
   . "Connection: close" instead of "Connection: closed" (Gustavo)
 
 - Core:
+  . Fixed bug #61374 (html_entity_decode tries to decode code points that don't
+    exist in ISO-8859-1). (Gustavo)
   . Fixed bug #61273 (call_user_func_array with more than 16333 arguments 
     leaks / crashes). (Laruence)
   . Fixed bug #61225 (Incorect lexing of 0b00*+<NUM>). (Pierrick)
index 1d031195ba0ae9228a254ae79df803a706be97e3..5b47a8378800c9cacb5394d00befa5d0f0f45a9b 100644 (file)
@@ -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 (file)
index 0000000..b7fce11
--- /dev/null
@@ -0,0 +1,7 @@
+--TEST--
+Bug #61374: html_entity_decode tries to decode code points that don't exist in ISO-8859-1
+--FILE--
+<?php
+echo html_entity_decode('&OElig;', 0, 'ISO-8859-1');
+--EXPECT--
+&OElig;