You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have not sanitized output support for EDE,
cause all entities in generated JS/JSON are escaped by the
sanitizer when bound to a template.
Dirty fix might be:
--- src/Servant/EDE.hs 2016-01-20 17:39:19.137294389 +0300
+++ /b/servant-ede-0.5.1/src/Servant/EDE.hs 2016-01-20 13:48:17.102301746 +0300
@@ -32,6 +32,7 @@
module Servant.EDE
( -- * Combinators
HTML
+ , RawHTML
, Tpl
-- * Sending Haskell data to templates
@@ -240,15 +241,23 @@
-- passed to the template.
data HTML (file :: Symbol)
+data RawHTML (file :: Symbol)
+
-- | @text/html;charset=utf-8@
instance Accept (HTML file) where
contentType _ = "text" // "html" /: ("charset", "utf-8")
+instance Accept (RawHTML file) where
+ contentType _ = "text" // "html" /: ("charset", "utf-8")
+
-- | XSS-sanitizes data before rendering it
instance (KnownSymbol file, ToObject a) => MimeRender (HTML file) a where
mimeRender _ val = mimeRender (Proxy :: Proxy (Tpl (HTML file) file)) $
sanitizeObject (toObject val)
+instance (KnownSymbol file, ToObject a) => MimeRender (RawHTML file) a where
+ mimeRender _ val = mimeRender (Proxy :: Proxy (Tpl (RawHTML file) file)) $ toObject val
+
sanitizeObject :: Object -> Object
sanitizeObject = HM.fromList . map sanitizeKV . HM.toList
@@ -288,9 +297,10 @@
CTFiles (c ': cts) = Append (CTFile c) (CTFiles cts)
type family CTFile c :: [Symbol] where
- CTFile (HTML fp) = '[fp]
- CTFile (Tpl ct fp) = '[fp]
- CTFile a = '[]
+ CTFile (HTML fp) = '[fp]
+ CTFile (RawHTML fp) = '[fp]
+ CTFile (Tpl ct fp) = '[fp]
+ CTFile a = '[]
templates :: Proxy api -> Proxy (TemplateFiles api)
templates Proxy = Proxy
The text was updated successfully, but these errors were encountered:
Regarding your suggestion: yeah, that'd be nice. Hoping the Config work done in servant can help us store those settings, but since servant-ede only provides content types, I'm not entirely sure this is going to work. Again, @jkarni might know better, given that I haven't followed the work on Config closely.
It would be nice to have not sanitized output support for EDE,
cause all entities in generated JS/JSON are escaped by the
sanitizer when bound to a template.
Dirty fix might be:
The text was updated successfully, but these errors were encountered: