From 4fb67c1621f37b7cd4f0fb23cd8791475b3e25d4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 2 Mar 2022 10:52:51 +0100 Subject: [PATCH] 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. --- Userland/Libraries/LibWeb/DOM/Document.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp index c622b541b0..8f3a82a9cd 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.cpp +++ b/Userland/Libraries/LibWeb/DOM/Document.cpp @@ -1406,7 +1406,7 @@ ExceptionOr Document::validate_qualified_name(String Optional 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::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))