From 4cef851bd435e45d2b9a1ed26bcd282ad25d25b1 Mon Sep 17 00:00:00 2001 From: yincong Date: Mon, 4 Nov 2024 19:11:56 +0800 Subject: [PATCH 1/4] fix net/html oom --- html/parse.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/parse.go b/html/parse.go index 46a89eda6c..97369ef19c 100644 --- a/html/parse.go +++ b/html/parse.go @@ -836,6 +836,9 @@ func afterHeadIM(p *parser) bool { case DoctypeToken: // Ignore the token. return true + case ErrorToken: + // Stop parsing. + return true } p.parseImpliedToken(StartTagToken, a.Body, a.Body.String()) From 9f9c09f2027b3c5845864ec9532b3adff6227480 Mon Sep 17 00:00:00 2001 From: yincong Date: Mon, 4 Nov 2024 19:41:42 +0800 Subject: [PATCH 2/4] add unit test --- html/parse_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/html/parse_test.go b/html/parse_test.go index aa91f4c2b3..24b352e2ad 100644 --- a/html/parse_test.go +++ b/html/parse_test.go @@ -468,6 +468,7 @@ func TestParseFragmentForeignContentTemplates(t *testing.T) { srcs := []string{ "", "