From fcf89f04c65835dfb700c9f3ec2a0c33371610e1 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 7 Mar 2008 05:28:29 +0000 Subject: [PATCH] Require month names to be spelled out as English words, so that single characters that happen to be Roman numerals don't get detected as months. Thanks to John Darrington for reporting this bug. --- src/data/ChangeLog | 7 +++++++ src/data/format-guesser.c | 9 +++++++-- tests/formats/format-guesser.sh | 19 +++++-------------- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/data/ChangeLog b/src/data/ChangeLog index bde30360..f209233b 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,10 @@ +2008-03-06 Ben Pfaff + + * format-guesser.c (syntax): Require month names to be spelled out + as English words, so that single characters that happen to be + Roman numerals don't get detected as months. Thanks to John + Darrington for reporting this bug. + 2008-03-04 Ben Pfaff Patch #6441. Reviewed by John Darrington. diff --git a/src/data/format-guesser.c b/src/data/format-guesser.c index 78af8dfa..26c917b8 100644 --- a/src/data/format-guesser.c +++ b/src/data/format-guesser.c @@ -135,8 +135,13 @@ static struct date_syntax syntax[] = /* www */ { FMT_WKDAY, 1, {DT_WEEKDAY} }, - /* mmm */ - { FMT_MONTH, 1, {DT_MONTH} }, + /* mmm + + We require a spelled-out English month so that + single-character Roman numerals like "i" and "x" don't get + detected as months. The latter is particularly common in + the password field of /etc/passwd-like files. */ + { FMT_MONTH, 1, {DT_ENGLISH_MONTH} }, }; /* Number of recognized date syntax formats. */ diff --git a/tests/formats/format-guesser.sh b/tests/formats/format-guesser.sh index 37bd2bcc..ce98b126 100755 --- a/tests/formats/format-guesser.sh +++ b/tests/formats/format-guesser.sh @@ -94,6 +94,7 @@ sed -ne 's/#.*//;/^[ ]*$/!p' > $TEMPDIR/test-list <<'EOF' # Date and time formats. "01-OCT-1978" => DATE11 +"01-x-1978" => EDATE9 # Roman numeral for month. "01-13-99" => ADATE8 "1-13-99" => ADATE7 (ADATE8) "13-01-99" => EDATE8 @@ -135,20 +136,10 @@ sed -ne 's/#.*//;/^[ ]*$/!p' > $TEMPDIR/test-list <<'EOF' "jan" => MONTH3 "Feb" => MONTH3 "MAR" => MONTH3 -"i" => MONTH1 (MONTH3) -"ii" => MONTH2 (MONTH3) -"iii" => MONTH3 -"iiii" => A4 -"iv" => MONTH2 (MONTH3) -"v" => MONTH1 (MONTH3) -"vi" => MONTH2 (MONTH3) -"vii" => MONTH3 -"viii" => MONTH4 -"ix" => MONTH2 (MONTH3) -"viiii" => A5 -"x" => MONTH1 (MONTH3) -"xi" => MONTH2 (MONTH3) -"xii" => MONTH3 +"i" => A1 # Not detected as MONTH format. +"v" => A1 +"ix" => A2 +"x" => A1 "january" => MONTH7 "janaury" => MONTH7 "february" => MONTH8 -- 2.30.2