php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26987 XML data extraction bug
Submitted: 2004-01-21 03:41 UTC Modified: 2004-01-21 12:31 UTC
From: aeolianmeson at hotmail dot com Assigned:
Status: Closed Package: XML related
PHP Version: 4.3.4 OS: WinXP
Private report: No CVE-ID: None
 [2004-01-21 03:41 UTC] aeolianmeson at hotmail dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-21 05:45 UTC] sniper@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.


 [2004-01-21 12:31 UTC] aeolianmeson at hotmail dot com
I'm sorry-- your time is no longer needed. It turns out that it was a problem relating to a problem I have been having with key-value associative array pairs.

Thank you for your time,
Dustin
 [2004-01-21 12:31 UTC] aeolianmeson at hotmail dot com
I'm sorry-- your time is no longer needed. It turns out that it was a problem relating to a problem I have been having with key-value associative array pairs.

Thank you for your time,
Dustin
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon May 23 20:05:46 2022 UTC