Skip to content

Commit

Permalink
LibJS: Early return from Date string parsing on empty string
Browse files Browse the repository at this point in the history
Loading Ladybird on Github results in 37 debug logs about being unable
to parse an empty Date string. This log is intended to catch Date
formats we do not support to detect web compatability problems, which
makes this case not particuarly useful to log.

Instead of trying to parse all of the different date formats and
logging that the string is not valid, let's just return NAN immediately.
  • Loading branch information
shannonbooth authored and awesomekling committed Oct 13, 2024
1 parent f41cbfa commit ee35e93
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ static double parse_simplified_iso8601(ByteString const& iso_8601)

static double parse_date_string(VM& vm, ByteString const& date_string)
{
if (date_string.is_empty())
return NAN;

auto value = parse_simplified_iso8601(date_string);
if (isfinite(value))
return value;
Expand Down

0 comments on commit ee35e93

Please sign in to comment.