File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -214,6 +214,9 @@ pub(crate) mod function {
214214 Some ( offset_in_seconds)
215215 }
216216
217+ if input. contains ( ':' ) {
218+ return None ;
219+ }
217220 let mut split = input. split_whitespace ( ) ;
218221 let seconds = split. next ( ) ?;
219222 let seconds = match seconds. parse :: < SecondsSinceUnixEpoch > ( ) {
Original file line number Diff line number Diff line change @@ -13,6 +13,21 @@ fn special_time_is_ok_for_now() {
1313 ) ;
1414}
1515
16+ #[ test]
17+ fn parse_header_is_not_too_lenient ( ) {
18+ let now = SystemTime :: now ( ) ;
19+ for not_a_header_str in [ "2005-04-07T22:13:09" , "2005-04-07 22:13:09" ] {
20+ assert ! (
21+ gix_date:: parse_header( not_a_header_str) . is_none( ) ,
22+ "It's not timestamp-like, despite some leniency"
23+ ) ;
24+ assert ! (
25+ gix_date:: parse( not_a_header_str, Some ( now) ) . is_err( ) ,
26+ "it misses the timezone offset, so can't be parsed"
27+ ) ;
28+ }
29+ }
30+
1631#[ test]
1732fn short ( ) {
1833 assert_eq ! (
You can’t perform that action at this time.
0 commit comments