mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +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
Notes:
sideshowbarker
2024-07-19 05:57:49 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c8e0426ab94
1 changed files with 13 additions and 10 deletions
|
@ -2276,20 +2276,23 @@ Optional<EntityMatch> codepoints_from_entity(const StringView& entity)
|
|||
{ "vsupne;", 0x0228B, 0x0FE00 },
|
||||
};
|
||||
|
||||
// FIXME: Make case-insensitive
|
||||
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) };
|
||||
}
|
||||
EntityMatch match;
|
||||
|
||||
// FIXME: Make case-insensitive
|
||||
for (auto& double_codepoint_entity : double_codepoint_entities) {
|
||||
if (entity.starts_with(double_codepoint_entity.entity)) {
|
||||
return EntityMatch { { double_codepoint_entity.codepoint1, double_codepoint_entity.codepoint2 }, StringView(double_codepoint_entity.entity) };
|
||||
for (auto& single_codepoint_entity : single_codepoint_entities) {
|
||||
if (entity.starts_with(single_codepoint_entity.entity)) {
|
||||
if (match.entity.is_null() || entity.length() > match.entity.length())
|
||||
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
Reference in a new issue