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 734280 - wrong error column in structured error when parsing attribute values
wrong error column in structured error when parsing attribute values
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2014-08-05 12:29 UTC by jrgn.keil
Modified: 2014-08-07 09:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample XML file, containing an error at line 3 column 21 (244 bytes, text/xml)
2014-08-05 12:29 UTC, jrgn.keil
  Details
Simple testcase; parses xml file and reports error via structured error handler (549 bytes, text/plain)
2014-08-05 12:32 UTC, jrgn.keil
  Details
Suggested fix - update location when parsing attribute value (2.20 KB, patch)
2014-08-05 12:36 UTC, jrgn.keil
none Details | Review

Description jrgn.keil 2014-08-05 12:29:47 UTC
Created attachment 282556 [details]
Sample XML file, containing an error at line 3 column 21

libxml2 reports wrong error column numbers (field int2 in xmlError)
in structured error handler, after parsing XML attribute values.

Example XML:

<?xml version="1.0" encoding="UTF-8"?>
<root
xmlns="urn:colbug">&</root>
<!--
         1         2         3         4         5         6         7         8
12345678901234567890123456789012345678901234567890123456789012345678901234567890
-->

Expected location of the error would be line 3, column 21.

The actual location of the error is line 3, column 9:

$ ./xmlparse colbug2.xml 
colbug2.xml:3:9: xmlParseEntityRef: no name


The 12 characters of the xmlns attribute value "urn:colbug" are
not accounted for in the error column value.
Comment 1 jrgn.keil 2014-08-05 12:32:36 UTC
Created attachment 282557 [details]
Simple testcase; parses xml file and reports error via structured error handler

$ cc `xml2-config --cflags --libs` -o xmlparse xmlparse.c
$ ./xmlparse colbug2.xml 
colbug2.xml:3:9: xmlParseEntityRef: no name

Expected output is:
colbug2.xml:3:21: xmlParseEntityRef: no name
Comment 2 jrgn.keil 2014-08-05 12:36:18 UTC
Created attachment 282558 [details] [review]
Suggested fix - update location when parsing attribute value
Comment 3 Daniel Veillard 2014-08-07 09:36:43 UTC
Okay looks good, I wasn't sure it would work in the fallback case
xmlParseAttValueComplex() but it seems to be properly accounted there too
if I extend the URI with a non ascii character:

thinkpad:~/XML -> ./tst ../colbug2.xml
../colbug2.xml:3:20: xmlns: 'urn:colbugä' is not a valid URI

../colbug2.xml:3:22: xmlParseEntityRef: no name

thinkpad:~/XML -> 

  So fine, applied and commited
33f658c969501bb246f8d4c6d21772948c7bc965

   thanks !

Daniel