diff --git a/test/main.hs b/test/main.hs index 40b9af5..eb0bf56 100644 --- a/test/main.hs +++ b/test/main.hs @@ -11,9 +11,19 @@ test f actual expected = do let result = f actual result @?= expected -sanitized :: Text -> Text -> Expectation +sanitized, sanitizedB, sanitizedC :: Text -> Text -> Expectation sanitized = test sanitize sanitizedB = test sanitizeBalance +sanitizedC = test sanitizeCustom + +sanitizeCustom :: Text -> Text +sanitizeCustom = filterTags $ mySafeTags mySafeName mySanitizeAttr + where + mySafeName t = t `elem` myTags || safeTagName t + mySanitizeAttr (key, val) | key `elem` myAttrs = Just (key, val) + mySanitizeAttr x = sanitizeAttribute x + myTags = ["custtag"] + myAttrs = ["custattr"] main :: IO () main = hspec $ do @@ -87,3 +97,15 @@ main = hspec $ do sanitizedB "" "" it "interleaved" $ sanitizedB "helloworld" "helloworld" + + describe "customized white list" $ do + it "does not filter custom tags" $ do + let custtag = "

" + sanitizedC custtag custtag + it "filters non-custom tags" $ do + sanitizedC "

" "

" + it "does not filter custom attributes" $ do + let custattr = "

" + sanitizedC custattr custattr + it "filters non-custom attributes" $ do + sanitizedC "

" "

"