diff --git a/Text/HTML/SanitizeXSS.hs b/Text/HTML/SanitizeXSS.hs index 03b0460..81326ad 100644 --- a/Text/HTML/SanitizeXSS.hs +++ b/Text/HTML/SanitizeXSS.hs @@ -12,7 +12,9 @@ import Codec.Binary.UTF8.String ( encodeString, decodeString ) import Text.HTML.TagSoup sanitizeXSS :: String -> String -sanitizeXSS = renderTags . safeTags . parseTagsOptions parseOptions { optTagPosition = True } +sanitizeXSS = renderTagsOptions renderOptions { + optMinimize = \x -> x `elem` ["br","img"] + } . safeTags . parseTagsOptions parseOptions { optTagPosition = True } where safeTags :: [Tag String] -> [Tag String] safeTags [] = [] diff --git a/test.hs b/test.hs index f116d2c..fa6cc23 100644 --- a/test.hs +++ b/test.hs @@ -1,7 +1,7 @@ import Text.HTML.SanitizeXSS main = do - let test = " anchor " - let result = (sanitizeXSS test) - let expected = " anchor " - putStrLn $ if result == expected then "pass" else "failure parsing:" ++ (show test) ++ "\nexpected:" ++ (show expected) ++ "\nactual: " ++ (show result) + let test = " anchor

" + let actual = (sanitizeXSS test) + let expected = " anchor
" + putStrLn $ if actual == expected then "pass" else "failure parsing:" ++ (show test) ++ "\nexpected:" ++ (show expected) ++ "\nactual: " ++ (show actual)