Yesod Whamlet呈现为HTML而不进行转义

时间:2017-06-19 16:54:28

标签: haskell yesod

BufferedReader

高是这样的:

FileReader

问题是[whamlet| <h2> Here's the ES results: <h1> <ul> $forall EsHighlight high <- highlights re <li> <br> #{toHtml high} |] 没有呈现为html而是保持字符串。所以网页显示"large <em>bamboo</em>, and a crotched stick. Throwing these down, he poked under a pile of rubbish, and brought out a rough block of wood, pierced through and through with a hole, which was immediately clapped on the top of the jar. Then planting the crotched stick upright about two yards distant, and making it sustain one end of the <em>bamboo</em>, he inserted the other end of the latter into the hole in the block: concluding these arrangements by placing an old calabash under the farther end of the <em>bamboo</em>." 本身。 我该怎么办?

1 个答案:

答案 0 :(得分:3)

作为对XSS攻击的保护,Hamlet(以及底层的blaze-html库)的默认行为是通过toHtml函数转义所有HTML实体。如果您想避免转义,可以使用preEscapedToHtml。请注意,对用户提供的数据使用此功能非常危险