From 6e9969ded090fd69c8c7cf687eba2e23bde59b8f Mon Sep 17 00:00:00 2001 From: davidot Date: Wed, 12 Oct 2022 02:24:05 +0200 Subject: [PATCH] LibWeb: Make HTMLInputElement of type number use the new double parser --- Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index e287da7387..833f0adbf3 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -446,9 +446,10 @@ String HTMLInputElement::value_sanitization_algorithm(String value) const } } else if (type_state() == HTMLInputElement::TypeAttributeState::Number) { // If the value of the element is not a valid floating-point number, then set it to the empty string instead. - char* end_ptr; - auto val = strtod(value.characters(), &end_ptr); - if (!isfinite(val) || *end_ptr) + // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-floating-point-number-values + // 6. Skip ASCII whitespace within input given position. + auto maybe_double = value.to_double(TrimWhitespace::Yes); + if (!maybe_double.has_value() || !isfinite(maybe_double.value())) return ""; }