Re: [xml] CDATA sections do not count line numbers via SAX2 API



On Mon, Dec 22, 2003 at 03:07:38PM +0000, Dave Beckett wrote:
This is seen with 2.6.3 and CVS head.

Attached is a program cdata_bug.c that uses the SAX2 API to parse a
file and two files a.xml (with a CDATA section) and b.xml (without).

Both files contain a bad entity on line 8, but only the b.xml
line counting is correct.

Compiling against current libxml2 CVS head:

$ xml2-config --version
2.6.3
$ gcc -Wall -g `xml2-config --cflags` cdata_bug.c `xml2-config --libs` -o cdata_bug
$ ./cdata_bug a.xml
line 6 column 25 error - xmlParseEntityRef: expecting ';'
$ ./cdata_bug b.xml
line 8 column 25 error - xmlParseEntityRef: expecting ';'

This also fails with other SAX APIs such as in 2.5.x, 2.4.x - I tried
the last two of these series.

  Hum, I glanced over your code. I hate SAX ... callback based code is
just the worse design possible when it comes to understanding foreign 
code or debugging.
I'm not sure xmlSAXLocatorPtr still work. The way the line number is extracted
from a context is from ctxt->input informations. If your code gets
it that way through xmlSAX2GetLineNumber() then that should work, that's how
xmllint itself gets them.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]