From:             sta at netimage dot dk
Operating system: FreeBSD 7.1
PHP version:      5.2.11
PHP Bug Type:     XML related
Bug description:  libxml 2.7.3+ limits text nodes to 10MB

Description:
------------
Since version 2.7.3 libxml limits the maximum size of a single text node
to 10MB.
The limit can be removed with a new option, XML_PARSE_HUGE.
PHP has no way to specify this option to libxml.

I found the bug when making af SOAP-request where the reply contained a
20MB string.
SoapClient->__call() threw an exception: 'looks like we got no XML
document'

Using libxml_use_internal_errors(true) and libxml_get_errors() I could
narrow it down to a LibXMLError, code 5, 'Extra content at the end of the
document' - but the specified line and column was in the middle of a large
text node.

Using SoapClient->__getLastResponse() I saved the response to a file.
The xmllib program xmllint then revealed the cause:
> xmllint --noout soap_response.txt 
soap_response.txt:111834: error: xmlSAX2Characters: huge text node: out of
memory

We need a way to specify the XML_PARSE_HUGE option to libxml - perhaps
something like a new function: libxml_parse_huge(true).


Reproduce code:
---------------
<?php
$xml = "<?xml version='1.0' encoding='utf-8' standalone='yes' ?><test>" .
str_repeat('A', 12000000) . "</test>";
file_put_contents('file.xml', $xml);
$sxe = simplexml_load_file('file.xml');
if ($sxe instanceof SimpleXMLElement) {
        echo 'OK\n';
}
else {
        var_dump($sxe);
}


Expected result:
----------------
OK

Actual result:
--------------
PHP Warning:  simplexml_load_file(): file.xml:1: error: xmlSAX2Characters:
huge text node: out of memory in
/usr/dana/data/developers/holst/mobilmap/cron/xml.php on line 5
PHP Warning:  simplexml_load_file():
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
in /usr/dana/data/developers/holst/mobilmap/cron/xml.php on line 5
PHP Warning:  simplexml_load_file():                                      
                                         ^ in
/usr/dana/data/developers/holst/mobilmap/cron/xml.php on line 5
bool(false)

-- 
Edit bug report at http://bugs.php.net/?id=49660&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=49660&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=49660&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=49660&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=49660&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=49660&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=49660&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=49660&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=49660&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=49660&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=49660&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=49660&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=49660&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=49660&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=49660&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=49660&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=49660&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=49660&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=49660&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=49660&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=49660&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=49660&r=mysqlcfg

Reply via email to