LibWeb: Add parse_integer_digits methods

The rules for parsing integers don't specify an upper bound on the
value that can be returned, so the `parse_integer_digits` method can be
used to check whether the given arbitrarily-large StringView is valid
according to these rules. The `parse_integer` and
`parse_non_negative_integer` methods would fail for values larger than
2147483647 when they shouldn't have.
This commit is contained in:
Tim Ledbetter 2024-12-01 00:04:32 +00:00 committed by Andreas Kling
commit d02b763cd6
Notes: github-actions[bot] 2024-12-02 09:26:43 +00:00
2 changed files with 38 additions and 13 deletions

View file

@ -14,8 +14,10 @@
namespace Web::HTML {
Optional<i32> parse_integer(StringView string);
Optional<StringView> parse_integer_digits(StringView string);
Optional<u32> parse_non_negative_integer(StringView string);
Optional<StringView> parse_non_negative_integer_digits(StringView string);
Optional<double> parse_floating_point_number(StringView string);