[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36
John Goerzen
jgoerzen at complete.org
Fri Apr 23 15:11:34 UTC 2010
The following commit has been merged in the master branch:
commit 72e4282cf92decacec989e3ce7415cf1beae41da
Author: John Goerzen <jgoerzen at complete.org>
Date: Wed Oct 18 01:00:11 2006 +0100
Accept single-digit date
From: Joe Edmonds
I'm using MissingH.Wash.Mail.MailParser to parse mail sent from my
PalmOS treo using Versamail (3.1B). Versamail seems to set the hour
in the "Date" header to a single-digit date, in violation of RFC2822.
If you want to follow the "be strict in what you emit and permissive
in what you accept" philosophy, attached is a patch to accept this
format.
- Joe Edmonds
diff --git a/MissingH/Wash/Mail/MailParser.hs b/MissingH/Wash/Mail/MailParser.hs
index 3dbace9..eabcbee 100644
--- a/MissingH/Wash/Mail/MailParser.hs
+++ b/MissingH/Wash/Mail/MailParser.hs
@@ -320,7 +320,7 @@ data TimeOfDay2822 =
TimeOfDay2822 Int Int Int
deriving Show
parseTimeOfDay =
- do hh <- parseTwoDigits
+ do hh <- parseOneOrTwoDigits
char ':'
mm <- parseTwoDigits
ss <- option 0 (try $ do char ':'
@@ -361,3 +361,11 @@ parseTwoDigits =
d2 <- digit
return (10 * digitToInt d1 + digitToInt d2)
+parseOneOrTwoDigits =
+ do d1 <- digit
+ md2 <- option Nothing (digit >>= (return . Just))
+ case md2 of
+ Just d2 ->
+ return (10 * digitToInt d1 + digitToInt d2)
+ Nothing ->
+ return (digitToInt d1)
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list