Dear list,

I have an e-mail using a two-digit year in the Date: header. It seems
that INVALID_DATE is triggered.

The complete (but obfuscated) e-mail is here:

>From [EMAIL PROTECTED] Mon Jan 29 20:33:33 2007
Return-path: <[EMAIL PROTECTED]>
Envelope-to: [EMAIL PROTECTED]
Delivery-date: Mon, 29 Jan 2007 20:33:33 +0100
Received: from me by smtp.my.domain with local (Exim 3.36 #1 (Debian))
        id 1HBcFa-0000lB-00
        for <[EMAIL PROTECTED]>; Mon, 29 Jan 2007 20:33:10 +0100
Date: Mon, 29 Jan 07 20:33:10 +0100
To: [EMAIL PROTECTED]
Subject: INVALID_DATE test
Message-ID: <[EMAIL PROTECTED]>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.13 (2006-08-11)
From: Me <[EMAIL PROTECTED]>
Status: RO
Content-Length: 1
Lines: 1




Running this through spamc yields the following report:

X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on
jfr115.rotzorg.org
X-Spam-Level: ***
X-Spam-Status: No, score=3.9 required=5.0 tests=AWL,INVALID_DATE,
        NO_DNS_FOR_FROM,NO_RELAYS autolearn=disabled version=3.1.7

If i change the date to a 4-digit one, 2007, it doesn't give the
INVALID_DATE:

X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on
jfr115.rotzorg.org
X-Spam-Level: ***
X-Spam-Status: No, score=3.2 required=5.0
tests=AWL,NO_DNS_FOR_FROM,NO_RELAYS 
        autolearn=disabled version=3.1.7

So, wondering what the problem would be, i read the RFC. This says that
a 2-digit year is obsolete, but supported for backwards compatibility.

I found the spamassassin test regexp in
/usr/share/spamassassin/20_head_tests.cf:

header INVALID_DATE             Date !~
/^\s*(?:(?i:Mon|Tue|Wed|Thu|Fri|Sat|Sun)
,\s+)?[0-3\s]?[0-9]\s+(?i:Jan|Feb|Ma[ry]|Apr|Ju[nl]|Aug|Sep|Oct|Nov|Dec)\s+(?:[12][901])?[0-9]{2}\s+[0-2]?[0-9](?:\:[0-5][0-9]){1,2}\s+(?:[AP]M\s+)?(?:[+-][0-9]{4}|UT|[A-Z]{2,3}T)(?:\s+\(.*\))?\s*$/
 [if-unset: Wed, 31 Jul 2002 16:41:57 +0200]
describe INVALID_DATE           Invalid Date: header (not RFC 2822)

This regexp is easily broken down in little tests, and the year test
seem to be

(?:[12][901])?[0-9]{2}

This tells me: Optional 1 or 2 followed by a 9, 0, or 1 (probably trying to
match 19, 20 or 21 (we're good for another 193 years), and 2 digits.

I would think that "07" as year would be allowed, but the test (changing
07 to 2007) shows otherwise. I've tried the regexp in an online perl
regexp tester, and that showed that i am correct. 

Can anyone explain the error?

Sander De Graaf
-- 
"True, but until we get off our butts and write it, we have to use
something" -- markwalling on /.

Reply via email to