1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-27 18:50:07 +03:00

remove the warning for startDocument(), as it is used by glade (or

* legacy.c: remove the warning for startDocument(), as it is used by
  glade (or glade-python)
* parser.c relaxng.c xmlschemastypes.c: fixed an assorted set of
  invalid accesses found by running some Python based regression
  tests under valgrind. There is still a few leaks reported by the
  relaxng regressions which need some attention.
* doc/Makefile.am: fixed a make install problem c.f. #124539
* include/libxml/parserInternals.h: addition of xmlParserMaxDepth
  patch from crutcher
Daniel
This commit is contained in:
Daniel Veillard 2003-10-17 12:43:59 +00:00
parent 520f58544a
commit 4aede2e66b
7 changed files with 106 additions and 64 deletions

View File

@ -1,3 +1,15 @@
Fri Oct 17 14:38:54 CEST 2003 Daniel Veillard <daniel@veillard.com>
* legacy.c: remove the warning for startDocument(), as it is used by
glade (or glade-python)
* parser.c relaxng.c xmlschemastypes.c: fixed an assorted set of
invalid accesses found by running some Python based regression
tests under valgrind. There is still a few leaks reported by the
relaxng regressions which need some attention.
* doc/Makefile.am: fixed a make install problem c.f. #124539
* include/libxml/parserInternals.h: addition of xmlParserMaxDepth
patch from crutcher
Wed Oct 15 12:47:33 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: Marc Liyanage pointed out that xmlCleanupParser()

View File

@ -100,8 +100,10 @@ rebuild: libxml-sections.txt templates xml html api
install-data-local:
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/xml.html $(srcdir)/encoding.html $(srcdir)/FAQ.html $(srcdir)/structure.gif $(srcdir)/DOM.gif $(srcdir)/smallfootonly.gif $(srcdir)/redhat.gif $(srcdir)/libxml.gif $(srcdir)/w3c.png $(srcdir)/Libxml2-Logo-180x168.gif $(srcdir)/Libxml2-Logo-90x34.gif $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(TARGET_DIR)
-@INSTALL@ -m 0644 $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR)
$(mkinstalldirs) $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/*.html $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/*.png $(DESTDIR)$(TARGET_DIR)/html
-@INSTALL@ -m 0644 $(srcdir)/html/index.sgml $(DESTDIR)$(TARGET_DIR)/html
-(cd $(DESTDIR); gtkdoc-fixxref --module=libxml --html-dir=$(HTML_DIR))
-@(tar cf - tutorial | (cd $(DESTDIR)$(TARGET_DIR) && tar xvf -))

View File

@ -19,6 +19,15 @@
extern "C" {
#endif
/**
* xmlParserMaxDepth:
*
* arbitrary depth limit for the XML documents that we allow to
* process. This is not a limitation of the parser but a safety
* boundary feature.
*/
XMLPUBVAR unsigned int xmlParserMaxDepth;
/**
* XML_MAX_NAMELEN:
*

View File

@ -1084,7 +1084,8 @@ setDocumentLocator(void *ctx ATTRIBUTE_UNUSED,
void
startDocument(void *ctx)
{
DEPRECATED("startDocument")
/* don't be too painful for glade users */
/* DEPRECATED("startDocument") */
xmlSAX2StartDocument(ctx);
}

View File

@ -78,13 +78,13 @@
#endif
/**
* MAX_DEPTH:
* xmlParserMaxDepth:
*
* arbitrary depth limit for the XML documents that we allow to
* process. This is not a limitation of the parser but a safety
* boundary feature.
*/
#define MAX_DEPTH 1024
unsigned int xmlParserMaxDepth = 1024;
#define SAX2 1
@ -972,15 +972,13 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
return (0);
}
}
#ifdef MAX_DEPTH
if (ctxt->nodeNr > MAX_DEPTH) {
if (((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) {
xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
"Excessive depth in document: change MAX_DEPTH = %d\n",
MAX_DEPTH);
"Excessive depth in document: change xmlParserMaxDepth = %d\n",
xmlParserMaxDepth);
ctxt->instate = XML_PARSER_EOF;
return(0);
}
#endif
ctxt->nodeTab[ctxt->nodeNr] = value;
ctxt->node = value;
return (ctxt->nodeNr++);
@ -3101,6 +3099,8 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
}
if (name != NULL)
xmlFree(name);
if (*cur == 0)
break;
}
cur++;
}
@ -3810,10 +3810,16 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
return;
}
q = CUR_CHAR(ql);
if (q == 0)
goto not_terminated;
NEXTL(ql);
r = CUR_CHAR(rl);
if (r == 0)
goto not_terminated;
NEXTL(rl);
cur = CUR_CHAR(l);
if (cur == 0)
goto not_terminated;
len = 0;
while (xmlIsChar(cur) && /* checked */
((cur != '>') ||
@ -3866,6 +3872,11 @@ xmlParseComment(xmlParserCtxtPtr ctxt) {
xmlFree(buf);
}
ctxt->instate = state;
return;
not_terminated:
xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated\n", NULL);
xmlFree(buf);
}
/**
@ -5763,7 +5774,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
/*
* Check that this entity is well formed
*/
if ((value != NULL) &&
if ((value != NULL) && (value[0] != 0) &&
(value[1] == 0) && (value[0] == '<') &&
(xmlStrEqual(ent->name, BAD_CAST "lt"))) {
/*
@ -8776,7 +8787,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
if (ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) {
if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
@ -8786,7 +8798,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
enc = xmlDetectCharEncoding(&start[0], 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
@ -8938,13 +8950,15 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
*/
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
}
@ -10314,7 +10328,8 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
BAD_CAST "none", BAD_CAST "none");
if (enc == XML_CHAR_ENCODING_NONE) {
if ((enc == XML_CHAR_ENCODING_NONE) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
/*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
@ -10410,8 +10425,10 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
* plug some encoding conversion routines here.
*/
xmlPushInput(ctxt, input);
enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
xmlSwitchEncoding(ctxt, enc);
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
xmlSwitchEncoding(ctxt, enc);
}
if (input->filename == NULL)
input->filename = (char *) xmlCanonicPath(SystemID);
@ -10560,13 +10577,15 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
* plug some encoding conversion routines.
*/
GROW
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
}
/*
@ -10756,13 +10775,15 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
* plug some encoding conversion routines.
*/
GROW;
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
start[0] = RAW;
start[1] = NXT(1);
start[2] = NXT(2);
start[3] = NXT(3);
enc = xmlDetectCharEncoding(start, 4);
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
}
/*

View File

@ -6696,11 +6696,11 @@ xmlRelaxNGNormExtSpace(xmlChar * value)
/* don't try to normalize the inner spaces */
while (IS_BLANK(*cur))
cur++;
*start++ = *cur++;
if (*cur == 0) {
*start = 0;
return;
}
*start++ = *cur++;
} while (1);
}
}

View File

@ -2857,21 +2857,24 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
xmlSchemaFreeValue(q1);
return -1;
} else {
int ret = 0;
/* normalize y - 14:00 */
q2 = xmlSchemaDateNormalize(y, -(14 * SECS_PER_HOUR));
q2d = _xmlSchemaDateCastYMToDays(q2) + q2->value.date.day;
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(q2);
if (p1d > q2d)
return 1;
ret = 1;
else if (p1d == q2d) {
sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q2);
if (sec > 0.0)
return 1;
ret = 1;
else
return 2; /* indeterminate */
ret = 2; /* indeterminate */
}
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(q2);
if (ret != 0)
return(ret);
}
} else {
xmlSchemaFreeValue(p1);
@ -2899,28 +2902,25 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
xmlSchemaFreeValue(q1);
return -1;
} else {
int ret = 0;
/* normalize x + 14:00 */
p2 = xmlSchemaDateNormalize(x, (14 * SECS_PER_HOUR));
p2d = _xmlSchemaDateCastYMToDays(p2) + p2->value.date.day;
if (p2d > q1d) {
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2);
return 1;
ret = 1;
} else if (p2d == q1d) {
sec = TIME_TO_NUMBER(p2) - TIME_TO_NUMBER(q1);
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2);
if (sec > 0.0)
return 1;
ret = 1;
else
return 2; /* indeterminate */
ret = 2; /* indeterminate */
}
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
xmlSchemaFreeValue(p2);
if (ret != 0)
return(ret);
}
} else {
xmlSchemaFreeValue(p1);
@ -2932,6 +2932,7 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
* if the same type then calculate the difference
*/
if (x->type == y->type) {
int ret = 0;
q1 = xmlSchemaDateNormalize(y, 0);
q1d = _xmlSchemaDateCastYMToDays(q1) + q1->value.date.day;
@ -2939,26 +2940,22 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
p1d = _xmlSchemaDateCastYMToDays(p1) + p1->value.date.day;
if (p1d < q1d) {
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
return -1;
ret = -1;
} else if (p1d > q1d) {
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
return 1;
ret = 1;
} else {
double sec;
sec = TIME_TO_NUMBER(p1) - TIME_TO_NUMBER(q1);
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
if (sec < 0.0)
return -1;
ret = -1;
else if (sec > 0.0)
return 1;
ret = 1;
}
return 0;
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
return(ret);
}
switch (x->type) {