File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -527,7 +527,7 @@ func hasEpochTimestamp(s string) bool {
527527
528528 // a valid timestamp can have optional ':' in zone specifier
529529 // remove that if it exists so we have a single format
530- if ts [len (ts )- 3 ] == ':' {
530+ if len ( ts ) >= 3 && ts [len (ts )- 3 ] == ':' {
531531 ts = ts [:len (ts )- 3 ] + ts [len (ts )- 2 :]
532532 }
533533
Original file line number Diff line number Diff line change @@ -724,6 +724,14 @@ func TestHasEpochTimestamp(t *testing.T) {
724724 Input : "+++ file.txt\t 2019-03-21 12:34:56.789 -0700\n " ,
725725 Output : false ,
726726 },
727+ "notTimestamp" : {
728+ Input : "+++ file.txt\t random text\n " ,
729+ Output : false ,
730+ },
731+ "notTimestampShort" : {
732+ Input : "+++ file.txt\t 0\n " ,
733+ Output : false ,
734+ },
727735 }
728736
729737 for name , test := range tests {
You can’t perform that action at this time.
0 commit comments