Explorar o código

LibWeb: Fix int parsing in Document::shared_declarative_refresh_steps

We now have functions for parsing integers in a spec-compliant way. This
patch replaces the `to_uint` call with a call to the spec-compliant
`Web::HTML::parse_non_negative_integer` function.
Jonatan Klemets hai 1 ano
pai
achega
acd46b5974
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      Userland/Libraries/LibWeb/DOM/Document.cpp

+ 2 - 2
Userland/Libraries/LibWeb/DOM/Document.cpp

@@ -71,6 +71,7 @@
 #include <LibWeb/HTML/MessageEvent.h>
 #include <LibWeb/HTML/Navigable.h>
 #include <LibWeb/HTML/NavigationParams.h>
+#include <LibWeb/HTML/Numbers.h>
 #include <LibWeb/HTML/Origin.h>
 #include <LibWeb/HTML/Parser/HTMLParser.h>
 #include <LibWeb/HTML/Scripting/ClassicScript.h>
@@ -3370,8 +3371,7 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtr<HTML
     }
 
     // 7. Otherwise, set time to the result of parsing timeString using the rules for parsing non-negative integers.
-    // FIXME: Not sure if this exactly matches the spec's "rules for parsing non-negative integers".
-    auto maybe_time = time_string.to_uint<u32>();
+    auto maybe_time = Web::HTML::parse_non_negative_integer(time_string);
 
     // FIXME: Since we only collected ASCII digits, this can only fail because of overflow. What do we do when that happens? For now, default to 0.
     if (maybe_time.has_value() && maybe_time.value() < NumericLimits<int>::max() && !Checked<int>::multiplication_would_overflow(static_cast<int>(maybe_time.value()), 1000)) {