|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53004 xml parser fails if newline befor the XML-Declaration
Submitted: 2010-10-06 18:29 UTC Modified: 2010-10-06 18:54 UTC
From: php at oshahn dot de Assigned:
Status: Not a bug Package: *XML functions
PHP Version: 5.3.3 OS: Ubuntu 10.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: php at oshahn dot de
New email:
PHP Version: OS:


 [2010-10-06 18:29 UTC] php at oshahn dot de
If there is a newline befor the XML-declaration, the parser fails.
The only demand:
"The document type declaration MUST appear before the first element in the document."

Test script:

$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("\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".


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-10-06 18:32 UTC]
-Status: Open +Status: Bogus
 [2010-10-06 18:32 UTC]
Expected, that's part of the XML specifications.
 [2010-10-06 18:40 UTC] php at oshahn dot de
I don't think so.

A newline is not an element.
 [2010-10-06 18:54 UTC] php at oshahn dot de
Ok, I tested it on

I seems that you are right.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 02:01:29 2024 UTC