|  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
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: 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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
3 + 11 = ?
Subscribe to this entry?

 [2003-12-13 09:11 UTC]
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:
$xml ='<?xml version="1.0"?>

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));

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

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-13 11:04 UTC]
regression test added: ext/xml/test/bug26614.phpt
 [2004-03-29 00:46 UTC]
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]
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]
libxml bugs belong elsewhere..

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 06:06:02 2022 UTC