Skip to content

Commit

Permalink
Merge pull request #28 from tfausak/escape-apostrophes
Browse files Browse the repository at this point in the history
Escape apostrophes
  • Loading branch information
JustusAdam authored Mar 30, 2017
2 parents cf228c7 + 4a6d6ab commit 53a93a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Text/Mustache/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ escapeXML = concatMap $ \x -> IntMap.findWithDefault [x] (ord x) mp
xmlEntities :: [(String, String)]
xmlEntities =
[ ("quot", "\"")
, ("#39", "'")
, ("amp" , "&")
, ("lt" , "<")
, ("gt" , ">")
Expand Down
8 changes: 4 additions & 4 deletions test/unit/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ substituteSpec =
it "substitutes a html escaped value for a variable" $
substitute
(toTemplate [Variable escaped (NamedData ["name"])])
(object ["name" ~> ("<tag>" :: T.Text)])
`shouldBe` "&lt;tag&gt;"
(object ["name" ~> ("\" ' < > &" :: T.Text)])
`shouldBe` "&quot; &#39; &lt; &gt; &amp;"

it "substitutes raw value for an unescaped variable" $
substitute
(toTemplate [Variable unescaped (NamedData ["name"])])
(object ["name" ~> ("<tag>" :: T.Text)])
`shouldBe` "<tag>"
(object ["name" ~> ("\" ' < > &" :: T.Text)])
`shouldBe` "\" ' < > &"

it "substitutes a section when the key is present (and an empty object)" $
substitute
Expand Down

0 comments on commit 53a93a0

Please sign in to comment.