Summary
GNU date silently ignores unrecognized trailing word-tokens and parses the preceding number as an hour. parse_datetime errors out instead.
Found by a fuzz_date run on uutils/coreutils.
Reproduction
$ TZ=UTC /usr/bin/date -u -d '8j''+%H:%M:%S'08:00:00
$ echo$?0
$ TZ=UTC target/debug/coreutils date -u -d '8j''+%H:%M:%S'date: invalid date '8j'
$ echo$?1
$ TZ=UTC /usr/bin/date -u -d '8 j''+%H:%M:%S'08:00:00
$ TZ=UTC target/debug/coreutils date -u -d '8 j''+%H:%M:%S'date: invalid date '8 j'
Test (in uutils/coreutils integration suite)
#[test]fntest_date_ignores_unrecognized_trailing_tokens(){for input in["8j","8 j"]{new_ucmd!().env("TZ","UTC").arg("-u").arg("-d").arg(input).arg("+%H:%M:%S").succeeds().stdout_only("08:00:00\n");}}
Summary
GNU
datesilently ignores unrecognized trailing word-tokens and parses the preceding number as an hour.parse_datetimeerrors out instead.Found by a
fuzz_daterun onuutils/coreutils.Reproduction
Test (in
uutils/coreutilsintegration suite)