Bug #2618: XML error reporting bug
| From: | brad_jackson at inlet dot com | Date: | Wed, 27 Oct 1999 13:10:42 +0000 |
| Subject: | Bug #2618: XML error reporting bug | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-11943@lists.php.net to get a copy of this message | ||
From: brad_jackson@inlet.com
Operating system: Redhat Linux 5.2/6.0
PHP version: 3.0.12
PHP Bug Type: Misbehaving function
Bug description: XML error reporting bug
If there is a mismatched tag in XML and the parsing fails, when calling xml_get_current_line_number
or xml_get_current_column_number, the results are not consistent between runs. Here's a code
sample and results. I've noticed that if I initialize $done to FALSE, it doesn't happen,
but I don't know how that could be related. I also tried shortening the XML sample, but then
it doesn't happen either. I've seen XML errors in the past that would cause Apache to seg
fault when calling the functions to get details about the XML error and this may be the same
problem.
<?php
$xml =
"<ABCDEFGH>\n<ABCDEFGHIJKLM>1234567890</ABCDEFGHIJKLM>\n<ABCDEFGH>";
// Note last closing tag should be "</ABCDEFGH>"
while(!$done)
{
for($i = 0; $i < 2; $i++)
{
$xmlParser = xml_parser_create();
xml_parse($xmlParser, $xml, TRUE);
$pass[$i]["Line"] = xml_get_current_line_number($xmlParser);
$pass[$i]["Column"] = xml_get_current_column_number($xmlParser);
xml_parser_free($xmlParser);
}
if($pass[0]["Line"] != $pass[1]["Line"] || $pass[0]["Column"] !=
$pass[1]["Column"])
{
echo "Pass1: Line " . $pass[0]["Line"] . ", Column " .
$pass[0]["Column"] . "<br>";
echo "Pass2: Line " . $pass[1]["Line"] . ", Column " .
$pass[1]["Column"];
$done = TRUE;
}
}
?>
Typical results:
Pass1: Line 3, Column 10
Pass2: Line 2, Column 52
Pass1: Line 1, Column 63
Pass2: Line 3, Column 10