1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00

- parser.c SAX.c: the new content parsing code raised an

ugly bug in the characters() SAX callback. Found it
  just because of strangeness in XSLT XML Rec ouptut :-(
Daniel
This commit is contained in:
Daniel Veillard 2001-03-07 19:45:40 +00:00
parent 6c831207f8
commit 80f3257163
3 changed files with 29 additions and 11 deletions

View File

@ -1,3 +1,9 @@
Wed Mar 7 20:43:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* parser.c SAX.c: the new content parsing code raised an
ugly bug in the characters() SAX callback. Found it
just because of strangeness in XSLT XML Rec ouptut :-(
Wed Mar 7 16:50:22 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* Makefile.am: Martin Baulig suggested to add -lm

9
SAX.c
View File

@ -1189,7 +1189,8 @@ characters(void *ctx, const xmlChar *ch, int len)
}
#endif
} else {
if ((xmlNodeIsText(lastChild)) && (ctxt->nodemem != 0)) {
int isText = xmlNodeIsText(lastChild);
if ((isText) && (ctxt->nodemem != 0)) {
#ifndef XML_USE_BUFFER_CONTENT
/*
* The whole point of maintaining nodelen and nodemem,
@ -1220,6 +1221,12 @@ characters(void *ctx, const xmlChar *ch, int len)
#else
xmlTextConcat(lastChild, ch, len);
#endif
} else if (isText) {
xmlTextConcat(lastChild, ch, len);
if (ctxt->node->children != NULL) {
ctxt->nodelen = xmlStrlen(lastChild->content);
ctxt->nodemem = ctxt->nodelen + 1;
}
} else {
/* Mixed content, first time */
lastChild = xmlNewTextLen(ch, len);

View File

@ -2450,15 +2450,17 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {
continue; /* while */
}
nbchar = in - ctxt->input->cur;
if (IS_BLANK(*ctxt->input->cur) &&
areBlanks(ctxt, ctxt->input->cur, nbchar)) {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(ctxt->userData,
ctxt->input->cur, nbchar);
} else {
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData,
ctxt->input->cur, nbchar);
if (nbchar > 0) {
if (IS_BLANK(*ctxt->input->cur) &&
areBlanks(ctxt, ctxt->input->cur, nbchar)) {
if (ctxt->sax->ignorableWhitespace != NULL)
ctxt->sax->ignorableWhitespace(ctxt->userData,
ctxt->input->cur, nbchar);
} else {
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData,
ctxt->input->cur, nbchar);
}
}
ctxt->input->cur = in;
if (*in == 0xD) {
@ -2471,7 +2473,10 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {
}
in--;
}
if ((*in == '<') || (*in == '&')) {
if (*in == '<') {
return;
}
if (*in == '&') {
return;
}
SHRINK;