php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35027 Specific proper XML code breaks xml parser
Submitted: 2005-10-30 19:08 UTC Modified: 2005-10-31 06:31 UTC
From: php at puntloos dot nl Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.0.5 OS: Linux Debian 2.6.13
Private report: No CVE-ID: None
 [2005-10-30 19:08 UTC] php at puntloos dot nl
Description:
------------
I've got a specific, properly formatted (as far as I can tell) RSS file that breaks the XML parser.

Reproduce code:
---------------
<?php
$url="http://130.89.22.201/break.rss";
$data=@fread(fopen("$url","r"),140000) or die("Cant open $url!");
$myar=getXmlData($data);
function getXmlData($xml_doc) {
        $parser = xml_parser_create();
        xml_parse_into_struct($parser,$xml_doc,$vals,$index) or die(xml_error_string(xml_get_error_code($parser)));
        xml_parser_free($parser);
}
?>

Expected result:
----------------
I expect it not to produce "Invalid document end" with the rss file (http://130.89.22.201/break.rss)

Actual result:
--------------
It procudes "Invalid document end" :P

Somehow it seems to do with the total size of the RSS file but I've parsed way bigger files.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-30 19:47 UTC] php at puntloos dot nl
Normally I would be the first to say that my XML is lacking, at best, so maybe it's just bad XML that can be found by snipping off parts of the code until the error goes away.

But I've tried that.

If you remove -any- of the ITEMs of my 'break.rss' the situation fixes itself, so *I* cant narrow it down beyond what's in break.rss.
 [2005-10-31 06:31 UTC] chregu@php.net
fread does not necessarly give you 1400000 bytes back, but 
max. this amount of data. use file_get_contents or loop 
through fread.

You would have realized that error with a simple "print $data" 
...

And btw, there's no xml version=2.0.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 02:01:29 2024 UTC