After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 116841 - zero-length prefix accepted, and validity error not raised
zero-length prefix accepted, and validity error not raised
Status: VERIFIED FIXED
Product: libxml2
Classification: Platform
Component: general
2.5.7
Other Windows
: Normal normal
: ---
Assigned To: Daniel Veillard
Daniel Veillard
Depends on:
Blocks:
 
 
Reported: 2003-07-06 19:50 UTC by Tobi
Modified: 2009-08-15 18:40 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tobi 2003-07-06 19:50:58 UTC
Hi

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg
  PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/SVG/DTD/svg10.dtd" >
<svg
  xmlns:="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
<title>foo</title>
</svg>

Note the colon after "xmlns" in line 6.

It may be well-formed, but I don't think zero-length prefixes are legal.
http://www.w3.org/TR/REC-xml-names/#ns-decl
  [2] PrefixedAttName  ::= 'xmlns:' NCName
http://www.w3.org/TR/REC-xml-names/#NT-NCName
  [4] NCName  ::= (Letter | '_') (NCNameChar)* 

RXP
http://www.cogsci.ed.ac.uk/~richard/rxp.html
says (rxp -V -N -s -x):~

Warning: Undeclared attribute xmlns: for element svg
 in unnamed entity at line 6 char 9 of
 file:///C:/foo.txt
Error: Attribute name xmlns: has empty local part
 in unnamed entity at line 6 char 9 of
 file:///C:/foo.txt

Xerces:

domcount foo.txt

Error at file C:\foo.txt, line 6, char 10
  Message: Attribute 'xmlns:' is not declared for element 'svg'

domcount -n foo.txt

Fatal Error at file C:\foo.txt, line 6, char 38
  Message: When namespaces are enabled, the colon cannot be the first
  or last character


xmllint, latest Window version
libxml2-2.5.7.win32\util\xmllint

xmllint --noout --valid --catalogs foo.txt

=> no error raised

I think that xmllint should raise at least one of the errors that
Xerces raises.

If it's namespace-aware by default, then it should raise an error for
a zero-length prefix (this would be raised even without the doctype
declaration).
And there is the invalidity error to be raised for the
attribute which is illegal SVG 1.0.


Tobi
Comment 1 Daniel Veillard 2003-07-24 16:10:10 UTC
Okay, right, that's a bad bug. It is now fixed in CVS:

gnome:~/XML -> xmllint --noout tst.svg
tst.svg:7: error: invalid namespace declaration 'xmlns:'
  xmlns:xlink="http://www.w3.org/1999/xlink">
                                            ^
gnome:~/XML -> xmllint --noout --valid tst.svg
tst.svg:7: error: invalid namespace declaration 'xmlns:'
  xmlns:xlink="http://www.w3.org/1999/xlink">
                                            ^
tst.svg:7: validity error: No declaration for attribute xmlns: of
element svg
  xmlns:xlink="http://www.w3.org/1999/xlink">
                                            ^
gnome:~/XML ->

   thanks for the report !

Daniel
Comment 2 Tobi 2003-07-24 16:14:40 UTC
Happy to be of help :)

Tobi
Comment 3 Tobi 2003-07-24 16:21:24 UTC
P.S.
Regarding the error message:
Would it be possible to list the line containing the error, not the
one after it? eg

 xmlns:="http://www.w3.org/2000/svg"
       ^
not

  xmlns:xlink="http://www.w3.org/1999/xlink">
                                            ^

Tobi
Comment 4 Daniel Veillard 2003-07-24 18:06:17 UTC
Unfortunately no. The line number can only be associated to an
element, and the error is only caught at the SAX callback level
i.e. after the whole element start has been parsed, so no that
would be quite hard to achieve.

Daniel
Comment 5 Tobi 2003-07-25 08:26:49 UTC
I see, but then people don't see the erratic code when looking at the
error message.

Perhaps you could list the whole element? eg

[...] error: invalid namespace declaration 'xmlns:'
<svg
  xmlns:="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">

[...] validity error: No declaration for attribute xmlns: of
element svg
<svg
  xmlns:="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">

Tobi
Comment 6 Daniel Veillard 2003-07-25 16:10:11 UTC
Even that is impossible in general, the string for the beginning
of the element my not even be available in memory anymore.
All I can provide is a limited set of characters on the last
line. Yes this is a performance trade-off.

Daniel
Comment 7 Daniel Veillard 2003-08-11 10:36:15 UTC
This should be closed by release of libxml2-2.5.9,
                                                                     
          
  thanks,
                                                                     
          
Daniel