rrichards               Mon Dec 19 14:17:30 2005 EDT

  Added files:                 (Branch: PHP_5_1)
    /php-src/ext/xml/tests      bug35447.phpt 

  Modified files:              
    /php-src/ext/xml    compat.c 
  Log:
  MFH: Fixed bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
  add test
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/xml/compat.c?r1=1.44.2.2&r2=1.44.2.3&diff_format=u
Index: php-src/ext/xml/compat.c
diff -u php-src/ext/xml/compat.c:1.44.2.2 php-src/ext/xml/compat.c:1.44.2.3
--- php-src/ext/xml/compat.c:1.44.2.2   Wed Oct 12 13:58:10 2005
+++ php-src/ext/xml/compat.c    Mon Dec 19 14:17:30 2005
@@ -405,15 +405,12 @@
                efree(parser);
                return NULL;
        }
-       if (encoding != NULL) {
-               parser->parser->encoding = xmlStrdup(encoding);
 #if LIBXML_VERSION <= 20617
        /* for older versions of libxml2, allow correct detection of
         * charset in documents with a BOM: */
-       } else {
-               parser->parser->charset = XML_CHAR_ENCODING_NONE;
+       parser->parser->charset = XML_CHAR_ENCODING_NONE;
 #endif
-       }
+
        parser->parser->replaceEntities = 1;
        parser->parser->wellFormed = 0;
        if (sep != NULL) {

http://cvs.php.net/viewcvs.cgi/php-src/ext/xml/tests/bug35447.phpt?view=markup&rev=1.1
Index: php-src/ext/xml/tests/bug35447.phpt
+++ php-src/ext/xml/tests/bug35447.phpt
--TEST--
Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM)
--SKIPIF--
<?php
if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is 
not supported on this plattform");}
?>
--FILE--
<?php
$data = <<<END_OF_XML
\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e
<!DOCTYPE bundle [
    <!ELEMENT bundle (resource)+>
    <!ELEMENT resource (#PCDATA)>
    <!ATTLIST resource
              key CDATA #REQUIRED
              type (literal|pattern|sub) "literal"
              >
]>
<resource key="rSeeYou">A bient&amp;244;t</resource>
END_OF_XML;

$parser = xml_parser_create_ns('UTF-8');
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
$result = xml_parse_into_struct($parser, $data, $vals, $index);
xml_parser_free($parser);
var_dump($vals);
?>
--EXPECT--
array(1) {
  [0]=>
  array(5) {
    ["tag"]=>
    string(8) "resource"
    ["type"]=>
    string(8) "complete"
    ["level"]=>
    int(1)
    ["attributes"]=>
    array(2) {
      ["key"]=>
      string(7) "rSeeYou"
      ["type"]=>
      string(7) "literal"
    }
    ["value"]=>
    string(13) "A bient&244;t"
  }
}

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

Reply via email to