Bug #55531 [Opn]: Vertical tabs ignored by XMLWriter

From: Date: Thu, 01 Apr 2021 14:42:17 +0000
Subject: Bug #55531 [Opn]: Vertical tabs ignored by XMLWriter
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233122@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55531&edit=1 ID: 55531 Updated by: cmb@php.net Reported by: brianlmoon@php.net Summary: Vertical tabs ignored by XMLWriter Status: Open Type: Bug Package: XML Writer Operating System: Linux PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: While \v is indeed invalid for XML 1.0, it is valid for XML 1.1. We could entity-encode such characters for 1.0 documents, and that likely wouldn't cause a BC break, but we could also leave that to libxml2 (to my knowledge, handling of invalid characters is not even documented by them). But if we manually entity-encode, we should make sure to keep that consistent (at least for XMLWriter, but likely for all bundled XML extension as well). Not sure. And we should decide how to handle NUL bytes. Currently, the strings are truncated, what doesn't appear to be intentional. Previous Comments: ------------------------------------------------------------------------ [2011-08-29 16:01:35] pajoye@php.net XML 1.0 this character is not valid. Not sure if we should allow it, .net 2.x allows them optionally using settings.CheckCharacters = true;. But that|s something libxml deals with, PHP's xml extensions only rely on it to parse input or generate data. ------------------------------------------------------------------------ [2011-08-29 15:52:18] brianlmoon@php.net Description: ------------ When text contains vertical tabs, XMLWriter silently ignores them and generates invalid XML. This is not an issue where the text is invalid UTF-8. It is valid UTF-8 data. Vertical tabs are simply not allowed in XML by rule. I would expect XMLWriter to encode it as it would any other character not allowed in XML. I suspect that Test script: --------------- <?php $xml = new XmlWriter(); $xml->openMemory(); $xml->startDocument('1.0', 'UTF-8'); $xml->writeElement("test", "This data contains a \vvertical tab"); $xml->endElement(); $data = $xml->outputMemory(true); $sxml = simplexml_load_string($data); ?> Expected result: ---------------- Either an error or valid XML. Actual result: -------------- Invalid XML is silently created. For example, SimpleXML::addchild() throws a warning: SimpleXMLElement::asXML(): xmlEscapeEntities : char out of range when a vertical tab is present and the node is not added. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=55531&edit=1

« previous php.bugs (#233122) next »