mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +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: 2d7547921b
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1360
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 7 additions and 2 deletions
|
@ -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
|
// 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)
|
String normalize_local_date_and_time_string(String const& value)
|
||||||
{
|
{
|
||||||
VERIFY(value.count(" "sv) == 1);
|
if (auto spaces = value.count(" "sv); spaces > 0) {
|
||||||
return MUST(value.replace(" "sv, "T"sv, ReplaceMode::FirstOnly));
|
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
|
// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-time-string
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue