[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 14:58:23 UTC 2010


The following commit has been merged in the master branch:
commit 8a1fe69661ae1ca8bbc8abcfe0c0b65e95fb5ad6
Author: John Goerzen <jgoerzen at complete.org>
Date:   Wed Apr 27 20:25:51 2005 +0100

    Added more error checking to ParseDate

diff --git a/MissingH/Time/ParseDate.hs b/MissingH/Time/ParseDate.hs
index 2e01275..26389eb 100644
--- a/MissingH/Time/ParseDate.hs
+++ b/MissingH/Time/ParseDate.hs
@@ -167,7 +167,9 @@ pCalendarTime l fmt = doFmt fmt
     decode 'B' = (parseEnum $ map fst $ months l) >>= setMonth
     decode 'c' = doFmt (dateTimeFmt l)
     decode 'C' = read2 >>= \c -> updateYear (\y -> c * 100 + y `rem` 100)
-    decode 'd' = read2 >>= setDay
+    decode 'd' = read2 >>= \day -> if day > 31 || day < 1
+                                       then fail $ "Invalid day " ++ (show day)
+                                       else setDay day
     decode 'D' = doFmt "%m/%d/%y"
     decode 'e' = read2 >>= setDay
     decode 'h' = decode 'b'
@@ -176,7 +178,9 @@ pCalendarTime l fmt = doFmt fmt
     decode 'j' = read3 >>= setYDay
     decode 'k' = read2 >>= setHour
     decode 'l' = read2 >>= setHour12
-    decode 'm' = read2 >>= \mon -> setMonth (toEnum (mon-1))
+    decode 'm' = read2 >>= \mon -> if (mon-1) > fromEnum (maxBound :: Month)
+                                      then fail $ "Invalid month " ++ (show mon)
+                                      else setMonth (toEnum (mon-1))
     decode 'M' = read2 >>= setMin
     -- FIXME: strptime(3) accepts "arbitrary whitespace" for %n
     decode 'n' = char '\n' >> return ()

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list