diff --git a/src/Yesod/Csp/TH.hs b/src/Yesod/Csp/TH.hs
--- a/src/Yesod/Csp/TH.hs
+++ b/src/Yesod/Csp/TH.hs
@@ -154,5 +154,5 @@
   where comma = string ";"
 
 directive :: Parser DirectiveList
-directive = sepBy d separator <* endOfInput
+directive = sepBy (spaces *> d) separator <* (spaces *> endOfInput)
   where d = withSourceList <|> reportUri <|> sandbox
diff --git a/test/Test.hs b/test/Test.hs
--- a/test/Test.hs
+++ b/test/Test.hs
@@ -99,6 +99,11 @@
       assertEq "with th" [csp|img-src 'self' https:;  script-src https://foo.com|] result
       let url = fromJust $ escapeAndParseURI "https://foo.com"
       assertEq "with antiquoting" [csp|img-src 'self' https:; script-src $url|] result
+    yit "works with th and newlines" $ do
+      let attempt = [csp|
+        default-src 'self'
+      |]
+      assertEq "with th and newlines" attempt [DefaultSrc (Self :| [])]
 
 middlewareTest :: Spec
 middlewareTest = yesodSpecApp Test getApp $ do
diff --git a/yesod-csp.cabal b/yesod-csp.cabal
--- a/yesod-csp.cabal
+++ b/yesod-csp.cabal
@@ -2,7 +2,7 @@
 -- documentation, see http://haskell.org/cabal/users-guide/
 
 name:                yesod-csp
-version:             0.2.4.0
+version:             0.2.5.0
 synopsis:            Add CSP headers to Yesod apps
 description:         Add CSP headers to Yesod apps. This helps reduce exposure to XSS attacks and bad assets.
 license:             MIT
