diff --git a/Text/HTML/SanitizeXSS.hs b/Text/HTML/SanitizeXSS.hs
index 0ad3e0b..530e09d 100644
--- a/Text/HTML/SanitizeXSS.hs
+++ b/Text/HTML/SanitizeXSS.hs
@@ -21,7 +21,10 @@ sanitizeXSS = renderTagsOptions renderOptions {
safeTags m [] =
concatMap go $ Map.toList m
where
- go (name, i) = replicate i $ TagClose name
+ go (name, i)
+ | noClosing name = []
+ | otherwise = replicate i $ TagClose name
+ noClosing = flip elem ["br", "img"]
safeTags m (t@(TagClose name):tags)
| safeTagName name =
case Map.lookup name m of
diff --git a/test.hs b/test.hs
index 840f59b..80d603e 100644
--- a/test.hs
+++ b/test.hs
@@ -1,8 +1,8 @@
import Text.HTML.SanitizeXSS
main = do
- let test = " safeanchor
Unbalanced"
+ let test = " safeanchor
Unbalanced
"
let actual = (sanitizeXSS test)
- let expected = " safeanchor
Unbalanced"
+ let expected = " safeanchor
Unbalanced
"
putStrLn $ "testing: " ++ test
putStrLn $ if actual == expected then "pass" else "failure\n" ++ "\nexpected:" ++ (show expected) ++ "\nactual: " ++ (show actual)