Package: libxml2
Version: 2.9.4+dfsg1-2.2
Severity: normal
Tags: patch
--- Please enter the report below this line. ---
Hi.
When parsing an XML Document, libxml2 wrongly reports an error
(seemingly without further consequences) about colons not being allowed
in Processing-Instruction names.
This is not true. The XML Specification
(https://www.w3.org/TR/REC-xml/#sec-pi and
https://www.w3.org/TR/REC-xml/#NT-Name) explicitly allows a colon (':')
as part of a PITarget, which is a Name in the XML specifications terms.
The last Version of the XML Specification, where a colon was not allowed
in a processing instruction name is over 20 years old and I think can be
safely ignored by now: https://www.w3.org/TR/WD-xml-lang-970331#NT-Name
Attached is a test document (test.xml), which triggers the warning, when
used for example with xmlstarlet like this:
$ xmlstarlet fo test.xml
test.xml:2.8: colons are forbidden from PI names 'pi:pi'
<?pi:pi pi?>
^
<?xml version="1.0"?>
<root>
<?pi:pi pi?>
</root>
Also attached is a patch (libxml2_patch_colons_in_pinames.patch), that
removes the bit of code from libxml2, that triggers the message.
I am not sure about the side effects of the removed function-call, but
from the comments in the code it seems it should have aborted
processing. It specifically states for xmlNsErr: "Handle a fatal parser
error, i.e. violating Well-Formedness constraints". However it does not
really abort, which might warrant another bug report.
Regards
Andre
--- System information. ---
Architecture: Kernel: Linux 4.9.0-3-amd64
Debian Release: 9.0
500 unstable-debug debug.mirrors.debian.org 500 unstable
ftp2.de.debian.org 500 testing-debug debug.mirrors.debian.org 500
testing ftp2.de.debian.org 1 experimental-debug
ftp.de.debian.org 1 experimental ftp.de.debian.org
--- Package information. ---
Package's Depends field is empty.
Package's Recommends field is empty.
Package's Suggests field is empty.
--- parser.c 2017-05-11 09:46:59.227102287 +0200
+++ parser.c 2017-05-11 09:47:07.854898587 +0200
@@ -5180,10 +5180,6 @@
"xmlParsePITarget: invalid name prefix 'xml'\n",
NULL, NULL);
}
- if ((name != NULL) && (xmlStrchr(name, ':') != NULL)) {
- xmlNsErr(ctxt, XML_NS_ERR_COLON,
- "colons are forbidden from PI names '%s'\n", name, NULL, NULL);
- }
return(name);
}
<root>
<?pi:pi pi?>
</root>