]> granicus.if.org Git - php/commitdiff
- 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.

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

index d95be5d197e0155e11323f9ee8bbb436643a4640..65e63f41cc9f8668e75fd103fc35290dad0878de 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;