summaryrefslogtreecommitdiff
path: root/parser.c
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2012-07-19 20:36:25 +0800
committerDaniel Veillard <veillard@redhat.com>2012-07-23 14:24:28 +0800
commitf572a78d58bf4fdb91fba421ab64013638f71f43 (patch)
tree095de0fc32b57bf8b06f9d8dbb47a13a7321f315 /parser.c
parent5130481646e37a3076d0553191bd0ea2a417c6e5 (diff)
downloadlibxml2-f572a78d58bf4fdb91fba421ab64013638f71f43.tar.gz
More avoid quadratic behaviour
Diffstat (limited to 'parser.c')
-rw-r--r--parser.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/parser.c b/parser.c
index d61909c7..76d2f5e8 100644
--- a/parser.c
+++ b/parser.c
@@ -11172,9 +11172,13 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
xmlParsePI(ctxt);
+ ctxt->instate = XML_PARSER_CONTENT;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next != '!')) {
ctxt->instate = XML_PARSER_START_TAG;
break;
@@ -11373,13 +11377,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
+ ctxt->instate = XML_PARSER_MISC;
+ ctxt->progressive = 1;
ctxt->checkIndex = 0;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') &&
@@ -11464,13 +11472,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
+ ctxt->instate = XML_PARSER_PROLOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
if ((!terminate) &&
@@ -11512,14 +11524,17 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
ctxt->instate = XML_PARSER_EPILOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
if ((!terminate) &&
@@ -11790,6 +11805,11 @@ xmlParseCheckTransition(xmlParserCtxtPtr ctxt, const char *chunk, int size) {
return(1);
return(0);
}
+ if (ctxt->progressive == XML_PARSER_PI) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
return(1);
}