From 38ad1b8e2a9dc1bb24c2f8abf68ddcd7fb92bf12 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 5 Jul 2021 16:04:38 +0100 Subject: [PATCH] [Minor] Html: Fix another corner case --- src/libserver/html/html.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index e1550f411d..395648c0c3 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -179,8 +179,8 @@ html_check_balance(struct html_content *hc, if (hc->all_tags.empty()) { auto &&vtag = std::make_unique(); - vtag->id = tag->id; - vtag->flags = FL_VIRTUAL|FL_CLOSED; + vtag->id = Tag_HTML; + vtag->flags = FL_VIRTUAL; vtag->tag_start = 0; vtag->content_offset = 0; calculate_content_length(vtag.get()); @@ -191,9 +191,12 @@ html_check_balance(struct html_content *hc, else { vtag->parent = hc->root_tag; } + hc->all_tags.emplace_back(std::move(vtag)); + tag->parent = vtag.get(); - return vtag.get(); + /* Recursively call with a virtual tag inserted */ + return html_check_balance(hc, tag, tag_start_offset, tag_end_offset); } } @@ -1931,6 +1934,12 @@ TEST_CASE("html text extraction") { const std::vector> cases{ + {"\n" + "\n" + "

Hello. I have some bad news.\n" + "











\n" + "\n" + "", " Hello. I have some bad news.\n\n\n\n\n\n\n\n"}, {" \n" " \n" " a b a > b a < b a & b 'a "a"\n" -- 2.47.3