From:             aeolianmeson at hotmail dot com
Operating system: WinXP
PHP version:      4.3.4
PHP Bug Type:     XML related
Bug description:  XML data extraction bug

Description:
------------
Using Expat XML functions.

The character data handler will occasionally return only a first part of
data. It will be immediately called again and return the rest.

This bug only occurred around the 20th and 40th records in a dataset
containing about 80. This occurred with multiple data-files where the
consistency between records has been verified.

Dustin Oprea, PHP-programming extraordinaire

Sample:
<logentry><date>2004.01.21</date><time>01:33:38</time><ip>127.0.0.1</ip><querystring>INSERT
INTO residents VALUES (55, "Chambers", "Harveasha", '0', '0', '', '216',
'')</querystring><position>backup.php/3</position></logentry>


Reproduce code:
---------------
// gets the last label recorded
function getlabel()
{
        global $stack;

        $tagname = array_pop($stack);
        array_push($stack, $tagname);

        return $tagname;
}

// character-data handler
function havedata($parser, $data)
{
        global $recorddata;

        $data = trim($data);            
        if(strlen($data) == 0)
                return;

        $recorddata[getlabel()] = $data;
}


Expected result:
----------------
INSERT INTO residents VALUES (54, "Lewis", "Theresa", '0', '0', '', '215',
'')
TAG= position
backup.php/3
TAG= logentry
TAG= date
2004.01.21
TAG= time
01:33:38
TAG= ip
127.0.0.1
TAG= querystring
--> INSERT INTO residents VALUES (55, "Chambers", "Harveasha", '0', '0',
'', '216', '')
TAG= position
backup.php/3
TAG= logentry
TAG= date
2004.01.21
TAG= time
01:33:38
TAG= ip
127.0.0.1
TAG= querystring
INSERT INTO residents VALUES (56, "Pierrie", "Ghezell", '0', '0', '',
'216', '')
TAG= position

Actual result:
--------------
INSERT INTO residents VALUES (54, "Lewis", "Theresa", '0', '0', '', '215',
'')
TAG= position
backup.php/3
TAG= logentry
TAG= date
2004.01.21
TAG= time
01:33:38
TAG= ip
127.0.0.1
TAG= querystring
--> INSERT INTO residen
--> ts VALUES (55, "Chambers", "Harveasha", '0', '0', '', '216', '')
TAG= position
backup.php/3
TAG= logentry
TAG= date
2004.01.21
TAG= time
01:33:38
TAG= ip
127.0.0.1
TAG= querystring
INSERT INTO residents VALUES (56, "Pierrie", "Ghezell", '0', '0', '',
'216', '')
TAG= position

-- 
Edit bug report at http://bugs.php.net/?id=26987&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26987&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26987&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26987&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26987&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26987&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26987&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26987&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26987&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26987&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26987&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26987&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26987&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26987&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26987&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26987&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26987&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26987&r=float

Reply via email to