LibWeb: Fix logic error in Document::validate_qualified_name()

We were mixing up the "name character" and "name start character"
validation checks. Also, we were not checking the first character after
a colon against the "name start character" set.
This commit is contained in:
Andreas Kling 2022-03-02 10:52:51 +01:00
parent 7231c1c895
commit 4fb67c1621
Notes: sideshowbarker 2024-07-17 18:06:52 +09:00

View file

@ -1406,7 +1406,7 @@ ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(String
Optional<size_t> colon_offset;
bool in_name = false;
bool at_start_of_name = true;
for (auto it = utf8view.begin(); it != utf8view.end(); ++it) {
auto code_point = *it;
@ -1414,12 +1414,13 @@ ExceptionOr<Document::PrefixAndTagName> Document::validate_qualified_name(String
if (colon_offset.has_value())
return InvalidCharacterError::create("More than one colon (:) in qualified name.");
colon_offset = utf8view.byte_offset_of(it);
at_start_of_name = true;
continue;
}
if (in_name) {
if (at_start_of_name) {
if (!is_valid_name_start_character(code_point))
return InvalidCharacterError::create("Invalid start of qualified name.");
in_name = false;
at_start_of_name = false;
continue;
}
if (!is_valid_name_character(code_point))