From b86c26497565164bfc4109b1095f1eb424de0dc7 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sat, 1 Oct 2022 18:29:18 +0100 Subject: [PATCH] LibWeb: Replace incorrect uses of split_view() for whitespace splitting --- Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp | 2 +- Userland/Libraries/LibWeb/DOM/Element.cpp | 6 +++--- Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp b/Userland/Libraries/LibWeb/DOM/DOMTokenList.cpp index fa75e738fb1..68bcb90584a 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(' '); + auto split_values = value.split_view(Infra::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 863d33d35d1..e01a160d526 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -5,7 +5,6 @@ */ #include -#include #include #include #include @@ -34,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -328,7 +328,7 @@ CSS::CSSStyleDeclaration const* Element::inline_style() const void Element::parse_attribute(FlyString const& name, String const& value) { if (name == HTML::AttributeNames::class_) { - auto new_classes = value.split_view(is_ascii_space); + auto new_classes = value.split_view(Infra::is_ascii_whitespace); m_classes.clear(); m_classes.ensure_capacity(new_classes.size()); for (auto& new_class : new_classes) { @@ -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(' ')) { + for (auto& name : class_names.view().split_view(Infra::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) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index f813ccc5930..699123d66cd 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -75,7 +76,7 @@ void HTMLLinkElement::parse_attribute(FlyString const& name, String const& value // To determine which link types apply to a link, a, area, or form element, // the element's rel attribute must be split on ASCII whitespace. // The resulting tokens are the keywords for the link types that apply to that element. - auto parts = lowercased_value.split_view(' '); + auto parts = lowercased_value.split_view(Infra::is_ascii_whitespace); for (auto& part : parts) { if (part == "stylesheet"sv) m_relationship |= Relationship::Stylesheet;