From:
Operating system: Ubuntu 10.10
PHP version: 5.3.3
Package: *XML functions
Bug Type: Bug
Bug description:xml parser fails if newline befor the XML-Declaration
Description:
------------
If there is a newline befor the XML-declaration, the parser fails.
The w3.org only demand:
"The document type declaration MUST appear before the first element in the
document."
Test script:
---------------
<?php
$data = '<?xml version="1.0"?><foo>bar</foo>';
function test($data) {
print "try to parse: '" . htmlentities($data) . "'<br>\n";
$parser = xml_parser_create();
if (!xml_parse($parser, $data)) {
print "Error: " . xml_error_string(xml_get_error_code($parser)) .
"<br>";
print "Error in Line " . xml_get_current_line_number($parser) . "
Column " . xml_get_current_column_number($parser) . "<hr>\n";
} else {
print "works fine<hr>";
}
}
test($data);
test("\n" . $data);
Expected result:
----------------
I expect, that both test succeed.
Actual result:
--------------
Only the first test succeed, the second fails in Line 1 Column 21 "Reserved
XML Name".
--
Edit bug report at http://bugs.php.net/bug.php?id=53004&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53004&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53004&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53004&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53004&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53004&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53004&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53004&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53004&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53004&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53004&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53004&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53004&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53004&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53004&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53004&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53004&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53004&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53004&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53004&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53004&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53004&r=mysqlcfg