Bug #70556 [NEW]: The parser reports duplicate id's when there are none.
| From: | chauvaux at crestec dot co dot jp | Date: | Wed, 23 Sep 2015 05:27:23 +0000 |
| Subject: | Bug #70556 [NEW]: The parser reports duplicate id's when there are none. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-196175@lists.php.net to get a copy of this message | ||
From: chauvaux at crestec dot co dot jp
Operating system: Windows 2008
PHP version: 5.5.29
Package: DOM XML related
Bug Type: Bug
Bug description:The parser reports duplicate id's when there are none.
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.
--
Edit bug report at https://bugs.php.net/bug.php?id=70556&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70556&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70556&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70556&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70556&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70556&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70556&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70556&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70556&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70556&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70556&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70556&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70556&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70556&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70556&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70556&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70556&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70556&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70556&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70556&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70556&r=mysqlcfg