mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +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:
parent
deca1d8b77
commit
3e486f75ff
4 changed files with 18 additions and 17 deletions
|
@ -391,5 +391,20 @@ bool String::equals_ignoring_case(const StringView& other) const
|
|||
return true;
|
||||
}
|
||||
|
||||
String escape_html_entities(const StringView& html)
|
||||
{
|
||||
StringBuilder builder;
|
||||
for (size_t i = 0; i < html.length(); ++i) {
|
||||
if (html[i] == '<')
|
||||
builder.append("<");
|
||||
else if (html[i] == '>')
|
||||
builder.append(">");
|
||||
else if (html[i] == '&')
|
||||
builder.append("&");
|
||||
else
|
||||
builder.append(html[i]);
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue