You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This specifier is documented as being "parsing only" here, but we accept format strings from users (limited/validated) who may put %#z in the formatting sequence.
All other invalid cases (that I can see!) result in Err(std::fmt::Error) being returned:
returnErr(fmt::Error);// insufficient arguments for given format
This has the benefit of allowing the caller to handle the error when the timestamp formatter is invalid (as long as you're not using the infallible to_string()). This is one way we validate a user-provided strftime formatter - try and use it, catching any errors - but obviously this doesn't work for %#z because it immediately panics! Thsi was unexpected - we only discovered it through fuzz testing.
Is there a reason %#z panics over returning an error? I'd be happy to PR the change to return the error & test.
The text was updated successfully, but these errors were encountered:
@domodwyer It just so happens that we are looking at this code the last couple of days. In #1127 we try to come up with a way to not panic but find a good place to report en errors.
When attempting to format a timestamp with a strftime format string containing
%#z
it panics:chrono/src/format/mod.rs
Line 673 in 088b693
This specifier is documented as being "parsing only" here, but we accept format strings from users (limited/validated) who may put
%#z
in the formatting sequence.All other invalid cases (that I can see!) result in
Err(std::fmt::Error)
being returned:chrono/src/format/mod.rs
Line 571 in 088b693
This has the benefit of allowing the caller to handle the error when the timestamp formatter is invalid (as long as you're not using the infallible
to_string()
). This is one way we validate a user-provided strftime formatter - try and use it, catching any errors - but obviously this doesn't work for%#z
because it immediately panics! Thsi was unexpected - we only discovered it through fuzz testing.Is there a reason
%#z
panics over returning an error? I'd be happy to PR the change to return the error & test.The text was updated successfully, but these errors were encountered: