Ladybird: Do not include comment start/end sequence in its editable text

Currently, when editing a comment, the `<!--` and `-->` start and end
sequences would be included in the generated <input> field. This would
result in including that text in the updated comment text. So, for
example, in a comment such as:

    <!-- foo -->

Changing "foo" to "bar" would result in the comment:

    <!--<!-- bar -->-->

And this would repeatedly nest for each edit.
This commit is contained in:
Timothy Flynn 2023-12-09 17:10:10 -05:00 committed by Andreas Kling
parent 42c0ac9352
commit 6595e76fef
Notes: sideshowbarker 2024-07-17 05:58:46 +09:00

View file

@ -501,8 +501,10 @@ String InspectorClient::generate_dom_tree(JsonObject const& dom_tree)
auto comment = node.get_deprecated_string("data"sv).release_value();
comment = escape_html_entities(comment);
builder.appendff("<span data-node-type=\"comment\" class=\"hoverable editable comment\" {}>", data_attributes.string_view());
builder.appendff("&lt;!--{}--&gt;", comment);
builder.appendff("<span class=\"hoverable comment\" {}>", data_attributes.string_view());
builder.append("<span>&lt;!--</span>"sv);
builder.appendff("<span data-node-type=\"comment\" class=\"editable\">{}</span>", comment);
builder.append("<span>--&gt;</span>"sv);
builder.append("</span>"sv);
return;
}