代码拉取完成,页面将自动刷新
From 63fa7b922a169ed6b86a4c6678140795c28657f5 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <[email protected]>
Date: Sun, 20 Nov 2022 19:54:34 +0100
Subject: [PATCH 20/28] html: Fix check for end of comment in push parser
Make sure to reset checkIndex. Handle case where "--" or "--!" is at the
end of the buffer. Fix "avail" check in htmlParseOrTryFinish.
Reference: https://github.com/GNOME/libxml2/commit/c93679381c565f4c110c7a6110372bd6d0610308
Conflict: HTMLparser.c:<htmlParseLookupCommentEnd>,<htmlParseTryOrFinish>
---
HTMLparser.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/HTMLparser.c b/HTMLparser.c
index e0b32fe..746edf6 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -5405,14 +5405,22 @@ static int
htmlParseLookupCommentEnd(htmlParserCtxtPtr ctxt)
{
int mark = 0;
+ int offset;
int cur = CUR_PTR - BASE_PTR;
- while (mark >= 0) {
+ while (1) {
mark = htmlParseLookupSequence(ctxt, '-', '-', 0, 0);
- if ((mark < 0) ||
- (NXT(mark+2) == '>') ||
+ if (mark < 0)
+ break;
+ if ((NXT(mark+2) == '>') ||
((NXT(mark+2) == '!') && (NXT(mark+3) == '>'))) {
- return mark;
+ ctxt->checkIndex = 0;
+ break;
+ }
+ offset = (NXT(mark+2) == '!') ? 3 : 2;
+ if (mark + offset >= ctxt->input->end - ctxt->input->cur) {
+ ctxt->checkIndex = mark;
+ return(-1);
}
ctxt->checkIndex = cur + mark + 1;
}
@@ -5949,6 +5957,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
break;
}
} else {
+ if ((cur == '<') && (next == '!') && (avail < 4))
+ goto done;
/*
* Sometimes DOCTYPE arrives in the middle of the document
*/
@@ -5984,8 +5994,6 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
#endif
htmlParsePI(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
- } else if ((cur == '<') && (next == '!') && (avail < 4)) {
- goto done;
} else if ((cur == '<') && (next == '/')) {
ctxt->instate = XML_PARSER_END_TAG;
ctxt->checkIndex = 0;
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。