summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authordavidot <davidot@serenityos.org>2022-10-12 02:24:05 +0200
committerLinus Groh <mail@linusgroh.de>2022-10-23 15:48:45 +0200
commit6e9969ded090fd69c8c7cf687eba2e23bde59b8f (patch)
tree3ec546e8c295dc699f300efc1941b259355e3d29 /Userland/Libraries
parent8abd4f6102bb6368947adeab823bb6047ccbdd9e (diff)
downloadserenity-6e9969ded090fd69c8c7cf687eba2e23bde59b8f.zip
LibWeb: Make HTMLInputElement of type number use the new double parser
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp7
1 files 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 "";
}