diff options
| author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
|---|---|---|
| committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:35:13 -0400 |
| commit | 0a36161e13484a99ccf69bb38f206462d27cc6d6 (patch) | |
| tree | d5107db4b7369603ac7c753829e8972ee74949f7 /ext/xml/tests | |
| parent | ce7edc9b3c7370f32fec0bc7a8ec3e29ed9a5f61 (diff) | |
| download | php-upstream/5.1.2.tar.gz | |
Imported Upstream version 5.1.2upstream/5.1.2
Diffstat (limited to 'ext/xml/tests')
| -rw-r--r-- | ext/xml/tests/bug25666.phpt | 3 | ||||
| -rw-r--r-- | ext/xml/tests/bug26528.phpt | 4 | ||||
| -rw-r--r-- | ext/xml/tests/bug26614.phpt | 5 | ||||
| -rwxr-xr-x | ext/xml/tests/bug26614_libxml.phpt | 5 | ||||
| -rw-r--r-- | ext/xml/tests/bug27908.phpt | 4 | ||||
| -rw-r--r-- | ext/xml/tests/bug30266.phpt | 4 | ||||
| -rw-r--r-- | ext/xml/tests/bug32001.phpt | 85 | ||||
| -rwxr-xr-x | ext/xml/tests/bug32001b.phpt | 184 | ||||
| -rw-r--r-- | ext/xml/tests/bug35447.phpt | 49 | ||||
| -rw-r--r-- | ext/xml/tests/xml001.phpt | 16 | ||||
| -rw-r--r-- | ext/xml/tests/xml002.phpt | 16 | ||||
| -rw-r--r-- | ext/xml/tests/xml003.phpt | 16 | ||||
| -rw-r--r-- | ext/xml/tests/xml009.phpt | 1 | ||||
| -rw-r--r-- | ext/xml/tests/xml010.phpt | 1 |
14 files changed, 284 insertions, 109 deletions
diff --git a/ext/xml/tests/bug25666.phpt b/ext/xml/tests/bug25666.phpt index ce67ea8ed..e162d5a2b 100644 --- a/ext/xml/tests/bug25666.phpt +++ b/ext/xml/tests/bug25666.phpt @@ -2,7 +2,8 @@ Bug #25666 (XML namespaces broken in libxml-based SAX interface) --SKIPIF-- <?php -if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this platform");} ?> --FILE-- <?php diff --git a/ext/xml/tests/bug26528.phpt b/ext/xml/tests/bug26528.phpt index 2fa015a84..40a1c53c9 100644 --- a/ext/xml/tests/bug26528.phpt +++ b/ext/xml/tests/bug26528.phpt @@ -1,5 +1,9 @@ --TEST-- Bug #26528 (HTML entities are not being decoded) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> --FILE-- <?php $sample = "<?xml version=\"1.0\"?><test attr=\"angle<bracket\"/>"; diff --git a/ext/xml/tests/bug26614.phpt b/ext/xml/tests/bug26614.phpt index a8a91ae87..e1df1bbfd 100644 --- a/ext/xml/tests/bug26614.phpt +++ b/ext/xml/tests/bug26614.phpt @@ -1,7 +1,10 @@ --TEST-- Bug #26614 (CDATA sections skipped on line count) --SKIPIF-- -<?php if (defined("LIBXML_VERSION")) die('skip expat test'); ?> +<?php +require_once("skipif.inc"); +if (defined("LIBXML_VERSION")) die('skip expat test'); +?> --FILE-- <?php /* diff --git a/ext/xml/tests/bug26614_libxml.phpt b/ext/xml/tests/bug26614_libxml.phpt index 645bf7e75..782bdb193 100755 --- a/ext/xml/tests/bug26614_libxml.phpt +++ b/ext/xml/tests/bug26614_libxml.phpt @@ -1,7 +1,10 @@ --TEST-- Bug #26614 (CDATA sections skipped on line count) --SKIPIF-- -<?php if (!defined("LIBXML_VERSION")) die('skip libxml2 test'); ?> +<?php +require_once("skipif.inc"); +if (!defined("LIBXML_VERSION")) die('skip libxml2 test'); +?> --FILE-- <?php /* diff --git a/ext/xml/tests/bug27908.phpt b/ext/xml/tests/bug27908.phpt index abb856137..e60466fa1 100644 --- a/ext/xml/tests/bug27908.phpt +++ b/ext/xml/tests/bug27908.phpt @@ -1,5 +1,9 @@ --TEST-- Bug #27908 (default handler not being called) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> --FILE-- <?php diff --git a/ext/xml/tests/bug30266.phpt b/ext/xml/tests/bug30266.phpt index ebc0a270c..0a3a5ca46 100644 --- a/ext/xml/tests/bug30266.phpt +++ b/ext/xml/tests/bug30266.phpt @@ -1,5 +1,9 @@ --TEST-- Bug #30266 (Invalid opcode 137/1/8) +--SKIPIF-- +<?php +require_once("skipif.inc"); +?> --FILE-- <?php /* diff --git a/ext/xml/tests/bug32001.phpt b/ext/xml/tests/bug32001.phpt index 22f405ae5..e9780016c 100644 --- a/ext/xml/tests/bug32001.phpt +++ b/ext/xml/tests/bug32001.phpt @@ -1,10 +1,9 @@ --TEST-- -Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect) +Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using UTF-* --SKIPIF-- <?php - if (!extension_loaded('iconv')) { - die ("skip iconv extension not available\n"); - } +require_once("skipif.inc"); +if (!extension_loaded('iconv')) die ("skip iconv extension not available"); ?> --FILE-- <?php @@ -149,12 +148,6 @@ $suite = array( new testcase("UTF-16LE", 1, 0, 0), new testcase("UTF-16LE", 1, 1, 0), new testcase("UTF-16LE", 1, 1, 1), - new testcase("EUC-JP" , 0), - new testcase("EUC-JP" , 1), - new testcase("Shift_JIS", 0), - new testcase("Shift_JIS", 1), - new testcase("GB2312", 0), - new testcase("GB2312", 1), ); if (XML_SAX_IMPL == 'libxml') { @@ -413,75 +406,3 @@ array(3) { [2]=> string(42) "e38386e382b9e383883ae38386e382b9e3838833: " } -Encoding: EUC-JP -XML Prologue: present -Chunk size: all data at once -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} -Encoding: EUC-JP -XML Prologue: present -Chunk size: 1 byte(s) -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} -Encoding: Shift_JIS -XML Prologue: present -Chunk size: all data at once -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} -Encoding: Shift_JIS -XML Prologue: present -Chunk size: 1 byte(s) -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} -Encoding: GB2312 -XML Prologue: present -Chunk size: all data at once -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} -Encoding: GB2312 -XML Prologue: present -Chunk size: 1 byte(s) -BOM: not prepended -array(3) { - [0]=> - string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" - [1]=> - string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" - [2]=> - string(42) "e38386e382b9e383883ae38386e382b9e3838833: " -} diff --git a/ext/xml/tests/bug32001b.phpt b/ext/xml/tests/bug32001b.phpt new file mode 100755 index 000000000..f4aea08e5 --- /dev/null +++ b/ext/xml/tests/bug32001b.phpt @@ -0,0 +1,184 @@ +--TEST-- +Bug #32001 (xml_parse*() goes into infinite loop when autodetection in effect), using EUC-JP, Shift_JIS, GB2312 +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (!extension_loaded('iconv')) die ("skip iconv extension not available"); +foreach(array('EUC-JP', 'Shift_JISP', 'GB2312') as $encoding) { + if (@xml_parser_create($encoding) === false) die("skip libxml2 does not support $encoding encoding"); +} +?> +--FILE-- +<?php +class testcase { + private $encoding; + private $bom; + private $prologue; + private $tags; + private $chunk_size; + + function testcase($enc, $chunk_size = 0, $bom = 0, $omit_prologue = 0) { + $this->encoding = $enc; + $this->chunk_size = $chunk_size; + $this->bom = $bom; + $this->prologue = !$omit_prologue; + $this->tags = array(); + } + + function start_element($parser, $name, $attrs) { + $attrs = array_map('bin2hex', $attrs); + $this->tags[] = bin2hex($name).": ".implode(', ', $attrs); + } + + function end_element($parser, $name) { + } + + function run() { + $data = ''; + + if ($this->prologue) { + $canonical_name = preg_replace('/BE|LE/i', '', $this->encoding); + $data .= "<?xml version=\"1.0\" encoding=\"$canonical_name\" ?>\n"; + } + + $data .= <<<HERE +<テスト:テスト1 xmlns:テスト="http://www.example.com/テスト/" テスト="テスト"> + <テスト:テスト2 テスト="テスト"> + <テスト:テスト3> + test! + </テスト:テスト3> + </テスト:テスト2> +</テスト:テスト1> +HERE; + + $data = iconv("UTF-8", $this->encoding, $data); + + $parser = xml_parser_create(NULL); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($parser, "start_element", "end_element"); + xml_set_object($parser, $this); + + if ($this->chunk_size == 0) { + $success = @xml_parse($parser, $data, true); + } else { + for ($offset = 0; $offset < strlen($data); + $offset += $this->chunk_size) { + $success = @xml_parse($parser, substr($data, $offset, $this->chunk_size), false); + if (!$success) { + break; + } + } + if ($success) { + $success = @xml_parse($parser, "", true); + } + } + + echo "Encoding: $this->encoding\n"; + echo "XML Prologue: ".($this->prologue ? 'present': 'not present'), "\n"; + echo "Chunk size: ".($this->chunk_size ? "$this->chunk_size byte(s)\n": "all data at once\n"); + echo "BOM: ".($this->bom ? 'prepended': 'not prepended'), "\n"; + + if ($success) { + var_dump($this->tags); + } else { + echo "[Error] ", xml_error_string(xml_get_error_code($parser)), "\n"; + } + } +} +$suite = array( + new testcase("EUC-JP" , 0), + new testcase("EUC-JP" , 1), + new testcase("Shift_JIS", 0), + new testcase("Shift_JIS", 1), + new testcase("GB2312", 0), + new testcase("GB2312", 1), +); + +if (XML_SAX_IMPL == 'libxml') { + $php = getenv('TEST_PHP_EXECUTABLE'); + preg_match("/^libxml2 Version.*\$/im", `$php -i`, $match); + echo $match[0], "\n"; +} else { + echo "libxml2 Version => NONE\n"; +} + +foreach ($suite as $testcase) { + $testcase->run(); +} + +// vim600: sts=4 sw=4 ts=4 encoding=UTF-8 +?> +--EXPECTF-- +libxml2 Version => %s +Encoding: EUC-JP +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: EUC-JP +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: Shift_JIS +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: Shift_JIS +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: GB2312 +XML Prologue: present +Chunk size: all data at once +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} +Encoding: GB2312 +XML Prologue: present +Chunk size: 1 byte(s) +BOM: not prepended +array(3) { + [0]=> + string(128) "e38386e382b9e383883ae38386e382b9e3838831: 687474703a2f2f7777772e6578616d706c652e636f6d2fe38386e382b9e383882f, e38386e382b9e38388" + [1]=> + string(60) "e38386e382b9e383883ae38386e382b9e3838832: e38386e382b9e38388" + [2]=> + string(42) "e38386e382b9e383883ae38386e382b9e3838833: " +} diff --git a/ext/xml/tests/bug35447.phpt b/ext/xml/tests/bug35447.phpt new file mode 100644 index 000000000..8cbb5e519 --- /dev/null +++ b/ext/xml/tests/bug35447.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #35447 (xml_parse_into_struct() chokes on the UTF-8 BOM) +--SKIPIF-- +<?php +require_once("skipif.inc"); +if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} +?> +--FILE-- +<?php +$data = <<<END_OF_XML +\xEF\xBB\xBF<?xml version="1.0" encoding="utf-8"?\x3e +<!DOCTYPE bundle [ + <!ELEMENT bundle (resource)+> + <!ELEMENT resource (#PCDATA)> + <!ATTLIST resource + key CDATA #REQUIRED + type (literal|pattern|sub) "literal" + > +]> +<resource key="rSeeYou">A bient&244;t</resource> +END_OF_XML; + +$parser = xml_parser_create_ns('UTF-8'); +xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); +$result = xml_parse_into_struct($parser, $data, $vals, $index); +xml_parser_free($parser); +var_dump($vals); +?> +--EXPECT-- +array(1) { + [0]=> + array(5) { + ["tag"]=> + string(8) "resource" + ["type"]=> + string(8) "complete" + ["level"]=> + int(1) + ["attributes"]=> + array(2) { + ["key"]=> + string(7) "rSeeYou" + ["type"]=> + string(7) "literal" + } + ["value"]=> + string(13) "A bient&244;t" + } +} diff --git a/ext/xml/tests/xml001.phpt b/ext/xml/tests/xml001.phpt index 6ee908e46..62d597c5f 100644 --- a/ext/xml/tests/xml001.phpt +++ b/ext/xml/tests/xml001.phpt @@ -35,42 +35,42 @@ xml_parser_free($xml_parser); function startElement($parser, $name, $attribs) { - print "\{$name"; + print '{'.$name; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { print " $k=\"$v\""; } } - print "}"; + print '}'; } function endElement($parser, $name) { - print "\{/$name}"; + print '{/'.$name.'}'; } function characterData($parser, $data) { - print "\{CDATA[$data]}"; + print '{CDATA['.$data.']}'; } function PIHandler($parser, $target, $data) { - print "\{PI[$target,$data]}"; + print '{PI['.$target.','.$data.']}'; } function defaultHandler($parser, $data) { if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print "\{ENTREF[$data]}"; + print '{ENTREF['.$data.']}'; } else { - print "\{?[$data]}"; + print '{?['.$data.']}'; } } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { - print "\{EXTENTREF[$openEntityNames,$base,$systemId,$publicId]}\n"; + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; return true; } diff --git a/ext/xml/tests/xml002.phpt b/ext/xml/tests/xml002.phpt index 978500292..8ae8dfbe6 100644 --- a/ext/xml/tests/xml002.phpt +++ b/ext/xml/tests/xml002.phpt @@ -15,37 +15,37 @@ class myclass { function startElement($parser, $name, $attribs) { - print "\{$name"; + print '{'.$name; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { print " $k=\"$v\""; } } - print "}"; + print '}'; } function endElement($parser, $name) { - print "\{/$name}"; + print '{/'.$name.'}'; } function characterData($parser, $data) { - print "\{CDATA[$data]}"; + print '{CDATA['.$data.']}'; } function PIHandler($parser, $target, $data) { - print "\{PI[$target,$data]}"; + print '{PI['.$target.','.$data.']}'; } function defaultHandler($parser, $data) { if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print "\{ENTREF[$data]}"; + print '{ENTREF['.$data.']}'; } else { - print "\{?[$data]}"; + print '{?['.$data.']}'; } } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { - print "\{EXTENTREF[$openEntityNames,$base,$systemId,$publicId]}\n"; + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; return true; } } diff --git a/ext/xml/tests/xml003.phpt b/ext/xml/tests/xml003.phpt index fa0984e89..311c81acf 100644 --- a/ext/xml/tests/xml003.phpt +++ b/ext/xml/tests/xml003.phpt @@ -15,37 +15,37 @@ class myclass { function startElement($parser, $name, $attribs) { - print "\{$name"; + print '{'.$name; if (sizeof($attribs)) { while (list($k, $v) = each($attribs)) { print " $k=\"$v\""; } } - print "}"; + print '}'; } function endElement($parser, $name) { - print "\{/$name}"; + print '{/'.$name.'}'; } function characterData($parser, $data) { - print "\{CDATA[$data]}"; + print '{CDATA['.$data.']}'; } function PIHandler($parser, $target, $data) { - print "\{PI[$target,$data]}"; + print '{PI['.$target.','.$data.']}'; } function defaultHandler($parser, $data) { if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";") { - print "\{ENTREF[$data]}"; + print '{ENTREF['.$data.']}'; } else { - print "\{?[$data]}"; + print '{?['.$data.']}'; } } function externalEntityRefHandler($parser, $openEntityNames, $base, $systemId, $publicId) { - print "\{EXTENTREF[$openEntityNames,$base,$systemId,$publicId]}\n"; + print '{EXTENTREF['.$openEntityNames.','.$base.','.$systemId.','.$publicId."]}\n"; return true; } } diff --git a/ext/xml/tests/xml009.phpt b/ext/xml/tests/xml009.phpt index 3b64e7b8b..84b89bb48 100644 --- a/ext/xml/tests/xml009.phpt +++ b/ext/xml/tests/xml009.phpt @@ -2,6 +2,7 @@ XML parser test, default namespaces --SKIPIF-- <?php +require_once("skipif.inc"); if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} ?> --FILE-- diff --git a/ext/xml/tests/xml010.phpt b/ext/xml/tests/xml010.phpt index 125e9c7b0..e96844212 100644 --- a/ext/xml/tests/xml010.phpt +++ b/ext/xml/tests/xml010.phpt @@ -2,6 +2,7 @@ XML parser test, attributes --SKIPIF-- <?php +require_once("skipif.inc"); if (! @xml_parser_create_ns('ISO-8859-1')) { die("skip xml_parser_create_ns is not supported on this plattform");} ?> --FILE-- |
