From 7c8ce42593b10c2993235ef7e458b0939c4b9819 Mon Sep 17 00:00:00 2001 From: MacDue Date: Sun, 2 Oct 2022 22:30:35 +0100 Subject: [PATCH] LibWeb: Fix string whitespace splitting mistake `.split_view(Infra::ASCII_WHITESPACE)` tries to split the string view on the string "\t\n\f\r " (not any of the individual characters of that string). The correct way to split this string views here is `.split_view_if(Infra::is_ascii_whitespace)`, this is a little inconsistent with String, so probably should be addressed. --- Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index 68bcb90584..3fc75d3f72 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp +++ b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp @@ -76,7 +76,7 @@ void DOMTokenList::associated_attribute_changed(StringView value) if (value.is_empty()) return; - auto split_values = value.split_view(Infra::ASCII_WHITESPACE); + auto split_values = value.split_view_if(Infra::is_ascii_whitespace); for (auto const& split_value : split_values) append_to_ordered_set(m_token_set, split_value); } diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index e01a160d52..3da9d40dd8 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -518,7 +518,7 @@ bool Element::is_active() const JS::NonnullGCPtr Element::get_elements_by_class_name(FlyString const& class_names) { Vector list_of_class_names; - for (auto& name : class_names.view().split_view(Infra::ASCII_WHITESPACE)) { + for (auto& name : class_names.view().split_view_if(Infra::is_ascii_whitespace)) { list_of_class_names.append(name); } return HTMLCollection::create(*this, [list_of_class_names = move(list_of_class_names), quirks_mode = document().in_quirks_mode()](Element const& element) {