From 0ee09c2ac5f52cce74fc32c1ff91ec980f2bbc85 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Fri, 1 Apr 2011 12:54:41 +0300 Subject: [PATCH] Remove bsToChars... helper functions --- Yesod/Core.hs | 3 ++- Yesod/Internal.hs | 27 ++------------------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/Yesod/Core.hs b/Yesod/Core.hs index 0d3e5143..92c5d53a 100644 --- a/Yesod/Core.hs +++ b/Yesod/Core.hs @@ -58,6 +58,7 @@ import Network.HTTP.Types (encodePath) import qualified Data.Text as TS import Data.Text (Text) import qualified Data.Text.Encoding as TE +import qualified Data.Text.Encoding.Error as TEE import Blaze.ByteString.Builder (Builder, toByteString) import Blaze.ByteString.Builder.Char.Utf8 (fromText) import Data.List (foldl') @@ -333,7 +334,7 @@ applyLayout' title body = fmap chooseRep $ defaultLayout $ do defaultErrorHandler :: Yesod y => ErrorResponse -> GHandler sub y ChooseRep defaultErrorHandler NotFound = do r <- waiRequest - let path' = bsToChars $ W.rawPathInfo r + let path' = TE.decodeUtf8With TEE.lenientDecode $ W.rawPathInfo r applyLayout' "Not Found" #if GHC7 [hamlet| diff --git a/Yesod/Internal.hs b/Yesod/Internal.hs index ab43a17f..3778143d 100644 --- a/Yesod/Internal.hs +++ b/Yesod/Internal.hs @@ -23,10 +23,6 @@ module Yesod.Internal , locationToHamlet , runUniqueList , toUnique - -- * UTF8 helpers - , bsToChars - , lbsToChars - , charsToBs -- * Names , sessionName , nonceKey @@ -38,16 +34,7 @@ import Text.Julius (Julius) import Data.Monoid (Monoid (..), Last) import Data.List (nub) -import qualified Data.ByteString as S -import qualified Data.ByteString.Lazy as L - import Data.Text (Text) -import qualified Data.Text as T -import qualified Data.Text.Encoding as T -import qualified Data.Text.Encoding.Error as T - -import qualified Data.Text.Lazy as LT -import qualified Data.Text.Lazy.Encoding as LT import Data.Typeable (Typeable) import Control.Exception (Exception) @@ -102,9 +89,9 @@ runUniqueList (UniqueList x) = nub $ x [] toUnique :: x -> UniqueList x toUnique = UniqueList . (:) -data Script url = Script { scriptLocation :: Location url, scriptAttributes :: [(T.Text, T.Text)] } +data Script url = Script { scriptLocation :: Location url, scriptAttributes :: [(Text, Text)] } deriving (Show, Eq) -data Stylesheet url = Stylesheet { styleLocation :: Location url, styleAttributes :: [(T.Text, T.Text)] } +data Stylesheet url = Stylesheet { styleLocation :: Location url, styleAttributes :: [(Text, Text)] } deriving (Show, Eq) newtype Title = Title { unTitle :: Html } @@ -113,16 +100,6 @@ newtype Head url = Head (Hamlet url) newtype Body url = Body (Hamlet url) deriving Monoid --- FIXME remove these functions -lbsToChars :: L.ByteString -> String -lbsToChars = LT.unpack . LT.decodeUtf8With T.lenientDecode - -bsToChars :: S.ByteString -> String -bsToChars = T.unpack . T.decodeUtf8With T.lenientDecode - -charsToBs :: String -> S.ByteString -charsToBs = T.encodeUtf8 . T.pack - nonceKey :: IsString a => a nonceKey = "_NONCE"