cataphract                               Fri, 08 Oct 2010 16:19:58 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=304208

Log:
- Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities 
with ENT_NOQUOTES and ISO-8859-1).

Bug: http://bugs.php.net/53021 (Verified) html_entity_decode not working with 
CP-1251 (5.2 only) and ISO-8859-1
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/standard/html.c
    A   php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug53021.phpt
    U   php/php-src/trunk/ext/standard/html.c
    A   php/php-src/trunk/ext/standard/tests/strings/bug53021.phpt

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-10-08 15:52:18 UTC (rev 304207)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-10-08 16:19:58 UTC (rev 304208)
@@ -25,6 +25,8 @@
 - Fixed possible crash in mssql_fetch_batch(). (Kalle)
 - Fixed inconsistent backlog default value (-1) in FPM on many systems. (fat)

+- Fixed bug #53021 (In html_entity_decode, failure to convert numeric entities
+  with ENT_NOQUOTES and ISO-8859-1) (Gustavo).
 - Fixed bug #52981 (Unicode casing table was out-of-date. Updated with
   UnicodeData-6.0.0d7.txt and included the source of the generator program with
   the distribution) (Gustavo).

Modified: php/php-src/branches/PHP_5_3/ext/standard/html.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/html.c    2010-10-08 15:52:18 UTC 
(rev 304207)
+++ php/php-src/branches/PHP_5_3/ext/standard/html.c    2010-10-08 16:19:58 UTC 
(rev 304208)
@@ -1020,7 +1020,12 @@
                                                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 @@
                                                                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;


Added: php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug53021.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug53021.phpt       
                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/strings/bug53021.phpt       
2010-10-08 16:19:58 UTC (rev 304208)
@@ -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("&#233;", ENT_QUOTES, "ISO-8859-1")));
+--EXPECT--
+array(1) {
+  [1]=>
+  string(2) "e9"
+}

Modified: php/php-src/trunk/ext/standard/html.c
===================================================================
--- php/php-src/trunk/ext/standard/html.c       2010-10-08 15:52:18 UTC (rev 
304207)
+++ php/php-src/trunk/ext/standard/html.c       2010-10-08 16:19:58 UTC (rev 
304208)
@@ -1020,7 +1020,12 @@
                                                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 @@
                                                                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;


Added: php/php-src/trunk/ext/standard/tests/strings/bug53021.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/strings/bug53021.phpt                  
        (rev 0)
+++ php/php-src/trunk/ext/standard/tests/strings/bug53021.phpt  2010-10-08 
16:19:58 UTC (rev 304208)
@@ -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("&#233;", ENT_QUOTES, "ISO-8859-1")));
+--EXPECT--
+array(1) {
+  [1]=>
+  string(2) "e9"
+}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to