From 5e3b2e3d313219126b03e9f8e4722a152a213f0c Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Mon, 29 Mar 2004 05:56:18 +0000 Subject: [PATCH] Test updated to test for additional libxml2/expat inconsistencies --- ext/xml/tests/bug26614.phpt | 77 ++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt index 1ff9d15782..14a4ea8a9f 100644 --- a/ext/xml/tests/bug26614.phpt +++ b/ext/xml/tests/bug26614.phpt @@ -2,7 +2,21 @@ Bug #26614 (CDATA sections skipped on line count) --FILE-- +/* +this test works fine with Expat but fails with libxml +which we now use as default + +further investigation has shown that not only line count +is skippet on CDATA sections but that libxml does also +show different column numbers and byte positions depending +on context and in opposition to what one would expect to +see and what good old Expat reported just fine ... +*/ + +$xmls = array(); + +// Case 1: CDATA Sections +$xmls["CDATA"] =' '; +// Case 2: replace some characters so that we get comments instead +$xmls["Comment"] =' + + +'; + +// Case 3: replace even more characters so that only textual data is left +$xmls["Text"] =' + +-!-- ATA[ +multi +line +CDATA +block +--- +'; + function startElement($parser, $name, $attrs) { - echo "<$name> at line ".xml_get_current_line_number($parser)."\n"; + printf("<$name> at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); } + function endElement($parser, $name) { - echo " at line ".xml_get_current_line_number($parser)."\n"; + printf(" at line %d, col %d (byte %d)\n", + xml_get_current_line_number($parser), + xml_get_current_column_number($parser), + xml_get_current_byte_index($parser)); +} + +function characterData($parser, $data) { + // dummy } -$xml_parser = xml_parser_create(); -xml_set_element_handler($xml_parser, "startElement", "endElement"); -xml_parse($xml_parser, $xml); -xml_parser_free($xml_parser); +foreach ($xmls as $desc => $xml) { + echo "$desc\n"; + $xml_parser = xml_parser_create(); + xml_set_element_handler($xml_parser, "startElement", "endElement"); + xml_set_character_data_handler($xml_parser, "characterData"); + if (!xml_parse($xml_parser, $xml, true)) + echo "Error: ".xml_error_string(xml_get_error_code($xml_parser))."\n"; + xml_parser_free($xml_parser); +} ?> --EXPECT-- - at line 2 - at line 9 +CDATA + at line 2, col 0 (byte 45) + at line 9, col 0 (byte 90) +Comment + at line 2, col 0 (byte 45) + at line 9, col 0 (byte 90) +Text + at line 2, col 0 (byte 45) + at line 9, col 0 (byte 90) -- 2.50.1