1. Luke Plant
  2. ella

Commits

Luke Plant  committed f4b7da2

Eliminated dependency on formatCalendarTime and strftime, since strftime does not work fully on target platform

  • Participants
  • Parent commits caf8006
  • Branches default

Comments (0)

Files changed (3)

File ella.cabal

View file
         network >= 2.1,
         SHA >= 1.0.2,
         old-time >= 1.0.0,
-        old-locale >= 1.0.0,
         unix >= 2.3,
         cgi >= 3001
   Exposed-Modules:

File src/Ella/Processors/Security.hs

View file
 import Ella.GenUtils (utf8, getTimestamp, randomStr, with, splitOn, exactParse)
 import Ella.Request
 import Ella.Response
-import System.Locale (defaultTimeLocale)
-import System.Time (ClockTime(..), toUTCTime, formatCalendarTime, CalendarTime)
+import System.Time (ClockTime(..), toUTCTime, toClockTime, ClockTime, CalendarTime)
 import qualified Data.Map as Map
 
 makeShaHash val = showDigest $ sha1 $ utf8 $ val
       mkHash :: String -> String -> String
       mkHash val expires = makeShaHash ("signedcookies:" ++ secret ++ ":" ++ expires ++ ":" ++ val)
 
+      -- NB: using formatCalendarTime with "%s" does not work on target
+      -- environment (CentOS 4.5), so use this alternative.
+      clockTimeToInteger :: ClockTime -> Integer
+      clockTimeToInteger (TOD x y) = x
+
       showExpires :: Maybe CalendarTime -> String
-      showExpires (Just x) = formatCalendarTime defaultTimeLocale "%s" x
+      showExpires (Just x) = show $ clockTimeToInteger $ toClockTime x
       showExpires Nothing = ""
 
 -- | CSRF protection

File testsuite/Tests/Ella/Processors/Security.hs

View file
 import Ella.Request
 import Ella.Response
 import Ella.TestUtils (mkGetReq, mkPostReq, addCookieValues)
-import System.Locale (defaultTimeLocale)
-import System.Time (toUTCTime, ClockTime(..), formatCalendarTime, CalendarTime)
+import System.Time (toUTCTime, ClockTime(..), CalendarTime, toClockTime)
 import Test.HUnit
 import qualified Data.ByteString.Lazy as BS
 import qualified Data.Map as Map
 signCookieVal :: String -> Maybe CalendarTime -> String
 signCookieVal val expires = (showDigest $ sha1 $ utf8 ("signedcookies:" ++ scp_secret ++ ":" ++ showExpires expires ++ ":" ++ val)) ++ ":" ++ showExpires expires ++ ":" ++ val
 
+clockTimeToInteger :: ClockTime -> Integer
+clockTimeToInteger (TOD x y) = x
+
 showExpires :: Maybe CalendarTime -> String
-showExpires (Just x) = formatCalendarTime defaultTimeLocale "%s" x
+showExpires (Just x) = show $ clockTimeToInteger $ toClockTime x
 showExpires Nothing = ""
 
 testSignedCookiesProcessor1 =