Bug #81351 [NEW]: xml_parse errors, but has no error code, when xmlns isn't a FQDN
From: dave dot lampert at rpm6 dot com
Operating system: Windows
PHP version: 8.0.9
Package: *XML functions
Bug Type: Bug
Bug description:xml_parse errors, but has no error code, when xmlns isn't a FQDN
Description:
------------
---
From manual page: https://php.net/function.xml-parse
---
If xml_parse tries to parse XML containing <X xmlns="something">, it
sees that "something" doesn't start with "http://" or "https://", so
xml_parse returns 0; however, xml_get_error_code also returns 0 ("No
error"). This only happens when parsing in fragments near that bad XML
namespace.
Test script:
---------------
<?php
class XMLProcessor
{
public function test()
{
$bad_xmlns = true;
$parser = xml_parser_create_ns('UTF-8');
xml_set_object($parser, $this);
$success = xml_parse($parser, '<?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="'.($bad_xmlns ? '' : 'http://').'example.org"><', 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>', 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";
}
}
(new XMLProcessor())->test();
Expected result:
----------------
xml_parse returned 1, xml_get_error_code = 0, xml_error_string = No
error
xml_parse returned 0, xml_get_error_code = {some number),
xml_error_string = {some description}
Actual result:
--------------
xml_parse returned 1, xml_get_error_code = 0, xml_error_string = No
error
xml_parse returned 0, xml_get_error_code = 0, xml_error_string = No
error
--
Edit bug report at https://bugs.php.net/bug.php?id=81351&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81351&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81351&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81351&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81351&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81351&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81351&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81351&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81351&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81351&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81351&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81351&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81351&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81351&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81351&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81351&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81351&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81351&r=mysqlcfg
Thread (5 messages)
- dave dot lampert at rpm6 dot com
- dave dot lampert at rpm6 dot comBug #81351 [Opn]: xml_parse errs, but has no error code, when xmlns isn't a FQDN
- cmb@php.netBug #81351 [Opn->Ver]: xml_parse errs, but has no error code, when xmlns isn't a FQDN
- cmb@php.netBug #81351 [PATCH]: xml_parse may fail, but has no error code
- git@php.netBug #81351 [Ver->Csd]: xml_parse may fail, but has no error code