1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 21:54:58 +00:00

AK: Move escape_html_entities() from LibHTML to AK

This sort of thing can be useful to things that don't want to link with
all of LibHTML.
This commit is contained in:
Andreas Kling 2020-02-13 08:46:00 +01:00
parent deca1d8b77
commit 3e486f75ff
4 changed files with 18 additions and 17 deletions

View file

@ -378,19 +378,3 @@ RefPtr<Document> parse_html_document(const StringView& html, const URL& url)
return document;
}
String escape_html_entities(const StringView& html)
{
StringBuilder builder;
for (size_t i = 0; i < html.length(); ++i) {
if (html[i] == '<')
builder.append("&lt;");
else if (html[i] == '>')
builder.append("&gt;");
else if (html[i] == '&')
builder.append("&amp;");
else
builder.append(html[i]);
}
return builder.to_string();
}