mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-26 10:03:34 +03:00
Allow to parse 1 byte HTML files
For https://bugzilla.gnome.org/show_bug.cgi?id=605740 File 1 byte long were not accepted by the HTML push parser
This commit is contained in:
parent
204f1f144c
commit
fdf990c2ef
35
HTMLparser.c
35
HTMLparser.c
@ -5343,10 +5343,23 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||
avail = in->length - (in->cur - in->base);
|
||||
else
|
||||
avail = in->buf->buffer->use - (in->cur - in->base);
|
||||
if (avail < 2)
|
||||
/*
|
||||
* no chars in buffer
|
||||
*/
|
||||
if (avail < 1)
|
||||
goto done;
|
||||
/*
|
||||
* not enouth chars in buffer
|
||||
*/
|
||||
if (avail < 2) {
|
||||
if (!terminate)
|
||||
goto done;
|
||||
else
|
||||
next = ' ';
|
||||
} else {
|
||||
next = in->cur[1];
|
||||
}
|
||||
cur = in->cur[0];
|
||||
next = in->cur[1];
|
||||
if ((cur == '<') && (next == '!') &&
|
||||
(in->cur[2] == '-') && (in->cur[3] == '-')) {
|
||||
if ((!terminate) &&
|
||||
@ -5496,8 +5509,22 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||
int failed;
|
||||
const htmlElemDesc * info;
|
||||
|
||||
if (avail < 2)
|
||||
/*
|
||||
* no chars in buffer
|
||||
*/
|
||||
if (avail < 1)
|
||||
goto done;
|
||||
/*
|
||||
* not enouth chars in buffer
|
||||
*/
|
||||
if (avail < 2) {
|
||||
if (!terminate)
|
||||
goto done;
|
||||
else
|
||||
next = ' ';
|
||||
} else {
|
||||
next = in->cur[1];
|
||||
}
|
||||
cur = in->cur[0];
|
||||
if (cur != '<') {
|
||||
ctxt->instate = XML_PARSER_CONTENT;
|
||||
@ -5507,7 +5534,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
if (in->cur[1] == '/') {
|
||||
if (next == '/') {
|
||||
ctxt->instate = XML_PARSER_END_TAG;
|
||||
ctxt->checkIndex = 0;
|
||||
#ifdef DEBUG_PUSH
|
||||
|
Loading…
x
Reference in New Issue
Block a user