|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-07-27 07:30 UTC] mioshchikhes at jobrouter dot de
Description:
------------
Vertical Tab character \v in the value of DOMElement::setAttribute produces invalid xml.
The XML can be saved, but it has an invalid character and cannot be read correctly. The behavior is reproducible.
Test script:
---------------
<?php
$dom = new DOMDocument();
$node = $dom->createElement('my-test');
$node->setAttribute('my-attribute', "vertical\vtabs");
$dom->appendChild($node);
$text = $dom->saveXML();
var_dump($text);
$dom = new DOMDocument();
$dom->loadXML($text);
var_dump($dom->saveXML());
Expected result:
----------------
Either an error or valid XML
Actual result:
--------------
An invalid xml is produced
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 20 09:00:01 2025 UTC |
Interesting you should mention that about "-->", because that leads to another libxml bug (if they consider it a bug): <?php $doc = new DOMDocument(); $node = $doc->appendChild(new DOMElement('my-test')); $comment = $node->appendChild(new DOMComment("This comment has a double hyphen -- something that isn't allowed in XML.")); echo $doc->saveXML(); $doc->save('c:/tmp/test.xml'); ?> Produces invalid output.