Reject empty time parse input
This commit is contained in:
parent
27d0258e1f
commit
62adc7a6a9
@ -163,7 +163,7 @@ RENDER(Request& context)
|
||||
String utc_year = time_format_utc("%Y", parsed_epoch);
|
||||
String local_year = time_format_local("%Y", parsed_epoch);
|
||||
String relative = time_format_relative(time() - 120, "recent %deltaS", 1, "medium %deltaM", 3600, "old %deltaH");
|
||||
check("time_format_local() / time_format_relative() / time_parse()", parsed_epoch == 5 && utc_year == "1970" && local_year != "" && contains(relative, "medium"), "parsed=" + std::to_string(parsed_epoch) + " utc=" + utc_year + " local=" + local_year + " rel=" + relative);
|
||||
check("time_format_local() / time_format_relative() / time_parse()", parsed_epoch == 5 && time_parse("") == 0 && time_parse(" ") == 0 && utc_year == "1970" && local_year != "" && contains(relative, "medium"), "parsed=" + std::to_string(parsed_epoch) + " empty=" + std::to_string(time_parse("")) + " utc=" + utc_year + " local=" + local_year + " rel=" + relative);
|
||||
|
||||
String crypto_random = random_bytes(16);
|
||||
String crypto_b64 = base64_encode("hello");
|
||||
|
||||
@ -459,6 +459,9 @@ String time_format_relative(u64 timestamp, String format_very_recent, u64 medium
|
||||
}
|
||||
u64 time_parse(String time_String)
|
||||
{
|
||||
time_String = trim(time_String);
|
||||
if(time_String == "")
|
||||
return(0);
|
||||
return(int_val(trim(shell_exec("date -u -d " + shell_escape(time_String) + " +'%s'"))));
|
||||
}
|
||||
u64 socket_connect(String host, u16 port)
|
||||
@ -1201,6 +1204,9 @@ String time_format_relative(u64 timestamp, String format_very_recent, u64 medium
|
||||
|
||||
u64 time_parse(String time_String)
|
||||
{
|
||||
time_String = trim(time_String);
|
||||
if(time_String == "")
|
||||
return(0);
|
||||
return(int_val(trim(shell_exec("date -u -d "+shell_escape(time_String)+" +'%s'"))));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user