#26614 [Opn]: linebreaks in CDATA sections ignored in line count
| From: | hholzgra@php.net | Date: | Sat, 13 Dec 2003 16:04:06 +0000 |
| Subject: | #26614 [Opn]: linebreaks in CDATA sections ignored in line count | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-52018@lists.php.net to get a copy of this message | ||
ID: 26614
Updated by: hholzgra@php.net
Reported By: hartmut@php.net
Status: Open
Bug Type: XML related
PHP Version: 5CVS-2003-12-13 (dev)
Assigned To: sterling
New Comment:
regression test added: ext/xml/test/bug26614.phpt
Previous Comments:
------------------------------------------------------------------------
[2003-12-13 09:11:38] 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
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26614&edit=1