mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 08:11:13 +00:00
LibWeb: Don't crash when normalizing a local datetime with a T separator
This commit is contained in:
parent
eb4e40bc49
commit
2d7547921b
Notes:
github-actions[bot]
2024-09-10 15:14:05 +00:00
Author: https://github.com/tcl3 Commit: https://github.com/LadybirdBrowser/ladybird/commit/2d7547921b9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1360 Reviewed-by: https://github.com/trflynn89 ✅
|
@ -160,8 +160,13 @@ bool is_valid_local_date_and_time_string(StringView value)
|
|||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-normalised-local-date-and-time-string
|
||||
String normalize_local_date_and_time_string(String const& value)
|
||||
{
|
||||
VERIFY(value.count(" "sv) == 1);
|
||||
return MUST(value.replace(" "sv, "T"sv, ReplaceMode::FirstOnly));
|
||||
if (auto spaces = value.count(" "sv); spaces > 0) {
|
||||
VERIFY(spaces == 1);
|
||||
return MUST(value.replace(" "sv, "T"sv, ReplaceMode::FirstOnly));
|
||||
}
|
||||
|
||||
VERIFY(value.count("T"sv) == 1);
|
||||
return value;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-time-string
|
||||
|
|
Loading…
Reference in a new issue