-
-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a patch to libxml2 to close HTML comments on
--!>
See guidance provided on incorrectly-closed comments here: https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-closed-comment
- Loading branch information
1 parent
dbb539c
commit 48e4a33
Showing
2 changed files
with
78 additions
and
6 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
patches/libxml2/0006-htmlParseComment-treat-as-if-it-closed-the-comment.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
From 15b28d8a99224e16ae8a7e7774ee3b6b6769dca3 Mon Sep 17 00:00:00 2001 | ||
From: Mike Dalessio <[email protected]> | ||
Date: Mon, 3 Aug 2020 17:36:05 -0400 | ||
Subject: [PATCH] htmlParseComment: treat `--!>` as if it closed the comment | ||
|
||
See guidance provided on incorrectly-closed comments here: | ||
|
||
https://html.spec.whatwg.org/multipage/parsing.html#parse-error-incorrectly-closed-comment | ||
|
||
This is a minimal patch to try to avoid merge conflicts. | ||
--- | ||
HTMLparser.c | 13 +++++++++++++ | ||
1 file changed, 13 insertions(+) | ||
|
||
diff --git a/HTMLparser.c b/HTMLparser.c | ||
index 7b6d689..0046642 100644 | ||
--- a/HTMLparser.c | ||
+++ b/HTMLparser.c | ||
@@ -3301,6 +3301,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { | ||
int r, rl; | ||
int cur, l; | ||
xmlParserInputState state; | ||
+ int possiblyIncorrectlyClosed = 0; | ||
|
||
/* | ||
* Check that there is a comment right here. | ||
@@ -3346,6 +3347,16 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { | ||
buf = tmp; | ||
} | ||
COPY_BUF(ql,buf,len,q); | ||
+ | ||
+ if (possiblyIncorrectlyClosed && cur == '>') { | ||
+ htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, | ||
+ "Comment incorrectly closed by '--!>'", NULL, NULL); | ||
+ buf[len-2] = 0; | ||
+ goto recover ; | ||
+ } | ||
+ | ||
+ possiblyIncorrectlyClosed = (q == '-' && r == '-' && cur == '!') ? 1 : 0 ; | ||
+ | ||
q = r; | ||
ql = rl; | ||
r = cur; | ||
@@ -3359,6 +3370,8 @@ htmlParseComment(htmlParserCtxtPtr ctxt) { | ||
} | ||
} | ||
buf[len] = 0; | ||
+ | ||
+recover: | ||
if (IS_CHAR(cur)) { | ||
NEXT; | ||
if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) && | ||
-- | ||
2.25.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters