mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 02:37:42 +00:00
LibWeb: Parser should prefer the longest matchable HTML entity
If we can match both "©" and "©" we should prefer the latter. Also remove invalid FIXME's about case insensitive entities.
This commit is contained in:
parent
1ef5d609d9
commit
c8e0426ab9
1 changed files with 13 additions and 10 deletions
|
@ -2276,20 +2276,23 @@ Optional<EntityMatch> codepoints_from_entity(const StringView& entity)
|
||||||
{ "vsupne;", 0x0228B, 0x0FE00 },
|
{ "vsupne;", 0x0228B, 0x0FE00 },
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Make case-insensitive
|
EntityMatch match;
|
||||||
for (auto& single_codepoint_entity : single_codepoint_entities) {
|
|
||||||
if (entity.starts_with(single_codepoint_entity.entity))
|
|
||||||
return EntityMatch { { single_codepoint_entity.codepoint }, StringView(single_codepoint_entity.entity) };
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Make case-insensitive
|
for (auto& single_codepoint_entity : single_codepoint_entities) {
|
||||||
for (auto& double_codepoint_entity : double_codepoint_entities) {
|
if (entity.starts_with(single_codepoint_entity.entity)) {
|
||||||
if (entity.starts_with(double_codepoint_entity.entity)) {
|
if (match.entity.is_null() || entity.length() > match.entity.length())
|
||||||
return EntityMatch { { double_codepoint_entity.codepoint1, double_codepoint_entity.codepoint2 }, StringView(double_codepoint_entity.entity) };
|
match = { { single_codepoint_entity.codepoint }, StringView(single_codepoint_entity.entity) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
for (auto& double_codepoint_entity : double_codepoint_entities) {
|
||||||
|
if (entity.starts_with(double_codepoint_entity.entity)) {
|
||||||
|
if (match.entity.is_null() || entity.length() > match.entity.length())
|
||||||
|
match = EntityMatch { { double_codepoint_entity.codepoint1, double_codepoint_entity.codepoint2 }, StringView(double_codepoint_entity.entity) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue