1
0
mirror of https://github.com/php/php-src.git synced 2026-04-19 22:11:12 +02:00
Files
archived-php-src/ext/xml/tests/bug81351.phpt
Christoph M. Becker 80a377e69b Fix #81351: xml_parse may fail, but has no error code
The fix for bug #73151[1] cured the symptoms, but not the root cause,
namely xmlParse() must not be called recursively.  Since that bugfix
also messed up the error handling, we basically revert it (but also
simplify the return), and then prevent calling the parser recursively.

[1] <f2a8a8c068>

Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Closes GH-7363.
2021-08-13 17:33:58 +02:00

29 lines
1.0 KiB
PHP

--TEST--
Bug #81351 (xml_parse may fail, but has no error code)
--SKIPIF--
<?php
if (!extension_loaded('xml')) die("skip xml extension not available");
?>
--FILE--
<?php
$xml = <<<XML
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<X xmlns="example.org">
XML;
$parser = xml_parser_create_ns('UTF-8');
$success = xml_parse($parser, $xml, false);
$code = xml_get_error_code($parser);
$error = xml_error_string($code);
echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
$success = xml_parse($parser, 'Y>', true);
$code = xml_get_error_code($parser);
$error = xml_error_string($code);
echo "xml_parse returned $success, xml_get_error_code = $code, xml_error_string = $error\r\n";
?>
--EXPECT--
xml_parse returned 1, xml_get_error_code = 0, xml_error_string = No error
xml_parse returned 0, xml_get_error_code = 5, xml_error_string = Invalid document end