aboutsummaryrefslogtreecommitdiffstats
path: root/parser.c
diff options
context:
space:
mode:
authorJuergen Keil <jrgn.keil@googlemail.com>2014-08-07 17:30:36 +0800
committerDaniel Veillard <veillard@redhat.com>2014-08-07 17:30:36 +0800
commit33f658c969501bb246f8d4c6d21772948c7bc965 (patch)
tree5ca7c1fb39bdf069112b146af93c96cd8989c13b /parser.c
parent5d4310af453a2220851b7063ebf165ce8b47494c (diff)
downloadandroid_external_libxml2-33f658c969501bb246f8d4c6d21772948c7bc965.tar.gz
android_external_libxml2-33f658c969501bb246f8d4c6d21772948c7bc965.tar.bz2
android_external_libxml2-33f658c969501bb246f8d4c6d21772948c7bc965.zip
wrong error column in structured error when parsing attribute values
For https://bugzilla.gnome.org/show_bug.cgi?id=734280 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 1234567890123456789012345678901234567890 --> 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.
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/parser.c b/parser.c
index fdb4514c..39d391b1 100644
--- a/parser.c
+++ b/parser.c
@@ -8932,9 +8932,12 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
xmlChar limit = 0;
const xmlChar *in = NULL, *start, *end, *last;
xmlChar *ret = NULL;
+ int line, col;
GROW;
in = (xmlChar *) CUR_PTR;
+ line = ctxt->input->line;
+ col = ctxt->input->col;
if (*in != '"' && *in != '\'') {
xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
return (NULL);
@@ -8947,6 +8950,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
* pure ASCII.
*/
limit = *in++;
+ col++;
end = ctxt->input->end;
start = in;
if (in >= end) {
@@ -8966,6 +8970,11 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
while ((in < end) && (*in != limit) &&
((*in == 0x20) || (*in == 0x9) ||
(*in == 0xA) || (*in == 0xD))) {
+ if (*in == 0xA) {
+ line++; col = 1;
+ } else {
+ col++;
+ }
in++;
start = in;
if (in >= end) {
@@ -8989,6 +8998,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
}
while ((in < end) && (*in != limit) && (*in >= 0x20) &&
(*in <= 0x7f) && (*in != '&') && (*in != '<')) {
+ col++;
if ((*in++ == 0x20) && (*in == 0x20)) break;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
@@ -9017,6 +9027,11 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
while ((in < end) && (*in != limit) &&
((*in == 0x20) || (*in == 0x9) ||
(*in == 0xA) || (*in == 0xD))) {
+ if (*in == 0xA) {
+ line++, col = 1;
+ } else {
+ col++;
+ }
in++;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
@@ -9049,6 +9064,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
while ((in < end) && (*in != limit) && (*in >= 0x20) &&
(*in <= 0x7f) && (*in != '&') && (*in != '<')) {
in++;
+ col++;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
GROW;
@@ -9078,6 +9094,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
if (*in != limit) goto need_complex;
}
in++;
+ col++;
if (len != NULL) {
*len = last - start;
ret = (xmlChar *) start;
@@ -9086,6 +9103,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
ret = xmlStrndup(start, last - start);
}
CUR_PTR = in;
+ ctxt->input->line = line;
+ ctxt->input->col = col;
if (alloc) *alloc = 0;
return ret;
need_complex: