From c5df0b0bf4f6d7211247d2bba2fc412881b954a3 Mon Sep 17 00:00:00 2001 From: Greg Weber Date: Fri, 25 Apr 2014 07:54:04 -0700 Subject: [PATCH] check for a colon and slashes after http --- yesod-static/Yesod/EmbeddedStatic/Css/Util.hs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/yesod-static/Yesod/EmbeddedStatic/Css/Util.hs b/yesod-static/Yesod/EmbeddedStatic/Css/Util.hs index 9219cba6..6287eb1e 100644 --- a/yesod-static/Yesod/EmbeddedStatic/Css/Util.hs +++ b/yesod-static/Yesod/EmbeddedStatic/Css/Util.hs @@ -60,12 +60,12 @@ checkForImage n@("background-image") v = parseBackgroundImage n v checkForImage n v = (n, Left v) parseBackgroundImage :: T.Text -> T.Text -> EithUrl -parseBackgroundImage n v = case P.parseOnly parseUrl v of - Left _ -> (n, Left v) -- Can't parse url - Right url - | "http" `T.isPrefixOf` url -> (n, Left v) - | "/" `T.isPrefixOf` url -> (n, Left v) - | otherwise -> (n, Right $ UrlReference url) +parseBackgroundImage n v = (n, case P.parseOnly parseUrl v of + Left _ -> Left v -- Can't parse url + Right url -> + if any (`T.isPrefixOf` url) ["http://", "https://", "/"] + then Left v + else Right $ UrlReference url) parseCssWith :: (T.Text -> T.Text -> EithUrl) -> T.Text -> Either String Css parseCssWith urlParser contents =