php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70556 The parser reports duplicate id's when there are none.
Submitted: 2015-09-23 05:27 UTC Modified: 2018-08-26 17:00 UTC
From: chauvaux at crestec dot co dot jp Assigned: cmb (profile)
Status: No Feedback Package: DOM XML related
PHP Version: 5.5.29 OS: Windows 2008
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chauvaux at crestec dot co dot jp
New email:
PHP Version: OS:

 

 [2015-09-23 05:27 UTC] chauvaux at crestec dot co dot jp
Description:
------------
Bug report

PHP: versions 5.5.24 and up (working as an Apache module
on a window box, and installed with XAMPP)
Module: XML DOM 
Method: load()

We are handling large XML documents (books). To make things easier to read,
we use a main XML document with the doctype header and a list of entity
declarations (one per chapter). The main XML document body is just a list of
entity references. Then we have separate files for each chapter.

Problem: when trying to load the main file, the parser reports duplicate id
values. It seems that the parser registers the values of the id attribute 
at the time it reads the entity declaration, and again when it actually 
imports the contents of the entity file.

NOTE: this problem did not occurred with version up to 5.5.23. It started at
version 5.5.24 and is still there at version 5.5.29.

To make things easier to whoever will be kind enough to try to fix this
bug, we have prepared 3 small files:

domtest.xml is the main file that we want to load in to the DOM object.
file_01.xml is the contents of one chapter.
domload.php is a small script that will allow you to replicate the error.

Thank you very much for your help.


Test script:
---------------
///////////////////////////////////////////////
Filename: domtest.xml: the main XML file to load

<?xml version='1.0' encoding='UTF-8'?>
<!--simple dtd for the purpose of this test-->
<!DOCTYPE book [ 
<!ELEMENT book (chapter)+ >
<!ELEMENT chapter (para)* >
<!ELEMENT para EMPTY >
<!ATTLIST para id ID #REQUIRED >

<!--entity declaration for one chapter; 
a real book would contain many of them-->
<!ENTITY file_01 SYSTEM "file_01.xml">
]>

<book>
<!--entity reference; 
a real book would contain many of them-->
&file_01;
</book>

//////////////////////////////////////////////
Filename: file_01.xml:

<chapter>
<para id='id_010'>aaa</para>
<para id='id_011'>bbb</para>
<para>ccc</para>
</chapter>

/////////////////////////////////////////////
domload.php

<?php

$dom = new DOMDocument();
$dom->resolveExternals = true;
$dom->substituteEntities = true;

$result = $dom->load('domtest.xml');
var_dump($result);
	
$dom->save('saved.xml');
	
?>

Expected result:
----------------
Since no id is replicated, a warning should not appear.

Actual result:
--------------
A warning telling that there are duplicate id's.
The file however loads correctly.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-10 12:13 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2018-08-10 12:13 UTC] cmb@php.net
While I can reproduce this with PHP 5.6.15 with libxml 2.9.2, I
can't with PHP 7.0.18 with libxml 2.9.4 nor with recent master and
libxml 2.9.8 (all Windows 10).  Since active support for PHP 5
ended long ago, it seems this ticket can be closed, unless
somebody else can reproduce it with any actively supported PHP
version[1].

[1] <http://php.net/supported-versions.php>
 [2018-08-26 17:00 UTC] cmb@php.net
-Status: Feedback +Status: No Feedback
 [2018-08-26 17:00 UTC] cmb@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 18 07:06:35 2022 UTC