php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26614 linebreaks in CDATA sections ignored in line count
Submitted: 2003-12-13 09:11 UTC Modified: 2005-02-13 22:54 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: hartmut@php.net Assigned: sterling (profile)
Status: Not a bug Package: XML related
PHP Version: 5CVS-2004-03-15 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hartmut@php.net
New email:
PHP Version: OS:

 

 [2003-12-13 09:11 UTC] hartmut@php.net
Description:
------------
xml_get_current_line_number() results differ between PHP 4 (expat) and PHP 5 (libxml2) as libxml2 seems to skip over CDATA sections when counting source lines

Reproduce code:
---------------
<?php
$xml ='<?xml version="1.0"?>
<data>
<![CDATA[
multi
line 
CDATA
block
]]>
</data>';

function startElement($parser, $name, $attrs) {
    echo "<$name> at line ".xml_get_current_line_number($parser)."\n";
}
function endElement($parser, $name) {
    echo "</$name> at line ".xml_get_current_line_number($parser)."\n";
}

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_parse($xml_parser, file_get_contents("test.xml", true));
xml_parser_free($xml_parser);
?>

Expected result:
----------------
<DATA> at line 2
</DATA> at line 9


Actual result:
--------------
<DATA> at line 2
</DATA> at line 4


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-13 11:04 UTC] hholzgra@php.net
regression test added: ext/xml/test/bug26614.phpt
 [2004-03-29 00:46 UTC] hholzgra@php.net
further investigation shows that not only the line number count 
is broken with CDATA but also column number and byte position
produced with libxml2 are in no way consistent with expat results

-> regression test updated
 [2004-03-31 12:19 UTC] rrichards@php.net
line numbering is fixed with libxml cvs. will be released in 2.6.9. column and byte position still an issue
 [2005-02-13 22:54 UTC] sniper@php.net
libxml bugs belong elsewhere..

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 19:01:30 2024 UTC