php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63589 XMLWriter handling of double-quotes not consistent with other libxml extensions
Submitted: 2012-11-23 18:56 UTC Modified: 2013-10-15 11:12 UTC
Votes:8
Avg. Score:4.6 ± 0.7
Reproduced:6 of 7 (85.7%)
Same Version:4 (66.7%)
Same OS:5 (83.3%)
From: franck at cassedanne dot com Assigned: rrichards (profile)
Status: Not a bug Package: XML Writer
PHP Version: 5.3.19, 5.4.9 OS: BSD, Linux, OSX
Private report: No CVE-ID: None
 [2012-11-23 18:56 UTC] franck at cassedanne dot com
Description:
------------
XMLWriter differs in its handling of double-quotes when compared to other libxml
based PHP extensions.

Double-quotes using XMLWriter are converted to htmlentities (i.e. '"').
Using SimpleXML or DOMDocument double-quotes stay unconverted.

It seems to me that XMLWriter should not be converting double-quotes either.

Tidy seems to also agree -- try the following in a CLI:
$ echo "<?xml encoding=\"UTF-8\"?><tag>&quot;</tag>" | tidy -xml -q

Maybe introducing a flag/constant such as ENT_NOQUOTES to toggle the conversion of 
these on and off might be pertinent.

Test script:
---------------
<?php
$x = new XMLWriter;
$x->openMemory();
$x->startDocument('1.0', 'UTF-8');
$x->writeElement('tag', '"');
$x->endDocument();
echo $x->flush();


Expected result:
----------------
<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag>"</tag>

Actual result:
--------------
<?xml version=\"1.0\" encoding=\"UTF-8\"?><tag>&quot;</tag>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-23 19:35 UTC] franck at cassedanne dot com
-PHP Version: 5.3.19 +PHP Version: 5.3.19, 5.4.9
 [2012-11-23 19:35 UTC] franck at cassedanne dot com
The same issue is present on PHP 5.4.9
 [2013-10-02 07:36 UTC] mike@php.net
-Status: Open +Status: Not a bug
 [2013-10-02 07:36 UTC] mike@php.net
It just forwards the call to libxml's xmlwriter, so nothing we can do about it.
 [2013-10-15 09:32 UTC] franck at cassedanne dot com
-Type: Bug +Type: Feature/Change Request
 [2013-10-15 09:32 UTC] franck at cassedanne dot com
All the other libxml based extensions out there (SimpleXML, DOMDocument, Tidy) which are all supposedly also forwarding their calls to that library, are consistent in the matter.

Only XMLWriter is acting differently -- maybe this should be changed to "Feature/Change Request" if it is not considered a Bug.
 [2013-10-15 10:20 UTC] mike@php.net
After all, it probably is a difference at the library level, maybe check with libxml upstream?
 [2013-10-15 10:25 UTC] pajoye@php.net
FYI tidy does not use libxml.
 [2013-10-15 10:49 UTC] franck at cassedanne dot com
Indeed, Tidy is not libxml based however it is handling double-quotes as expected as per the rest of the lot...

XMLWriter is the odd one out when it comes to it ;-)
 [2013-10-15 11:12 UTC] pajoye@php.net
-Assigned To: +Assigned To: rrichards
 [2013-10-15 11:12 UTC] pajoye@php.net
toughts on that? Can be solved using cdata but :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC