php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75768 libxml_get_errors function report different error in the same conditions
Submitted: 2018-01-05 18:47 UTC Modified: 2018-01-05 21:37 UTC
From: laurentiusilviu at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.6.33 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: laurentiusilviu at gmail dot com
New email:
PHP Version: OS:

 

 [2018-01-05 18:47 UTC] laurentiusilviu at gmail dot com
Description:
------------
I use XAMPP 5.6.32

I have this XML string:
<abc>
	<def>
		Content
	</def>
</abc>

and I used the functions from here: http://php.net/manual/ro/function.libxml-get-errors.php
to get XML errors

Test script:
---------------
Case 1:
In order to have an error in XML file, I replaced <dfe> with <dfeg>
Returned error:
Fatal Error 76: Opening and ending tag mismatch: defg line 3 and def Line: 5 Column: 11
Result seems to be ok;

Case 2:
In order to have the same error in XML file, I replaced <dfe> with <df>
Returned error:
Fatal Error 73: expected '>' Line: 5 Column: 6
Result: In my opinion, it is not relevant. I expected to have the same error message as in Case 1.




Expected result:
----------------
I expected to have the same result in both cases.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-01-05 21:37 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2018-01-05 21:37 UTC] requinix@php.net
This behavior comes from libxml, not PHP.
http://xmlsoft.org/bugs.html

Looks like it reads the end tag by trying to find the start tag's name then requiring that the next character is a '>'. Since "def" (</def>) begins with "de" (<de>) the parser thinks it finds the end tag correctly but errors since the next character is a 'f'. If you changed the start or end so that this doesn't happen (eg, <def> and </df>) you'll get the tag mismatched message.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 16:01:31 2024 UTC