From c4b82318f41ecc0a3e24fe5c8ca0a3f02816c3b1 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 10 Sep 2024 09:16:23 +0100 Subject: [PATCH] LibWeb: Ensure value sanitization algorithm trims whitespace if needed Previously, the value sanitization algorithm would not trim whitespace for inputs of type URL or email, if they didn't also contain any newlines. --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 158cfe9d526..c5ede0b19f2 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1361,6 +1361,7 @@ String HTMLInputElement::value_sanitization_algorithm(String const& value) const } return MUST(String::from_utf8(builder.string_view().trim(Infra::ASCII_WHITESPACE))); } + return MUST(value.trim(Infra::ASCII_WHITESPACE)); } else if (type_state() == HTMLInputElement::TypeAttributeState::Email) { // https://html.spec.whatwg.org/multipage/input.html#email-state-(type=email):value-sanitization-algorithm // FIXME: handle the `multiple` attribute @@ -1373,6 +1374,7 @@ String HTMLInputElement::value_sanitization_algorithm(String const& value) const } return MUST(String::from_utf8(builder.string_view().trim(Infra::ASCII_WHITESPACE))); } + return MUST(value.trim(Infra::ASCII_WHITESPACE)); } else if (type_state() == HTMLInputElement::TypeAttributeState::Number) { // https://html.spec.whatwg.org/multipage/input.html#number-state-(type=number):value-sanitization-algorithm // If the value of the element is not a valid floating-point number, then set it