GNOME Bugzilla – Bug 734280
wrong error column in structured error when parsing attribute values
Last modified: 2014-08-07 09:36:43 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.
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
Created attachment 282558 [details] [review] Suggested fix - update location when parsing attribute value
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