finish cabalizing package
This commit is contained in:
parent
632edcd7fc
commit
c9765daaed
@ -1,16 +1,14 @@
|
|||||||
module Text.HTML.SanitizeXSS where
|
module Text.HTML.SanitizeXSS where
|
||||||
|
|
||||||
import Data.Set (Set(..), member, notMember, fromList)
|
|
||||||
import Network.URI ( parseURIReference, URI (..) )
|
|
||||||
|
|
||||||
import Data.Char ( toLower, isLower, isUpper, isAlpha, isAscii,
|
|
||||||
isLetter, isDigit )
|
|
||||||
|
|
||||||
import Network.URI ( isAllowedInURI, escapeURIString, unEscapeString, uriScheme )
|
|
||||||
import Codec.Binary.UTF8.String ( encodeString, decodeString )
|
|
||||||
|
|
||||||
import Text.HTML.TagSoup
|
import Text.HTML.TagSoup
|
||||||
|
|
||||||
|
import Data.Set (Set(), member, fromList)
|
||||||
|
import Data.Char ( toLower, isAscii )
|
||||||
|
|
||||||
|
import Network.URI ( parseURIReference, URI (..),
|
||||||
|
isAllowedInURI, escapeURIString, unEscapeString, uriScheme )
|
||||||
|
import Codec.Binary.UTF8.String ( encodeString, decodeString )
|
||||||
|
|
||||||
sanitizeXSS :: String -> String
|
sanitizeXSS :: String -> String
|
||||||
sanitizeXSS = renderTagsOptions renderOptions {
|
sanitizeXSS = renderTagsOptions renderOptions {
|
||||||
optMinimize = \x -> x `elem` ["br","img"]
|
optMinimize = \x -> x `elem` ["br","img"]
|
||||||
|
|||||||
3
test.hs
3
test.hs
@ -4,4 +4,5 @@ main = do
|
|||||||
let test = " <a href='unsafe://hack.com'>anchor</a> <img src='evil://evil.com' /> <unsafe></foo> <bar /> <br></br> "
|
let test = " <a href='unsafe://hack.com'>anchor</a> <img src='evil://evil.com' /> <unsafe></foo> <bar /> <br></br> "
|
||||||
let actual = (sanitizeXSS test)
|
let actual = (sanitizeXSS test)
|
||||||
let expected = " <a>anchor</a> <img /> <br /> "
|
let expected = " <a>anchor</a> <img /> <br /> "
|
||||||
putStrLn $ if actual == expected then "pass" else "failure parsing:" ++ (show test) ++ "\nexpected:" ++ (show expected) ++ "\nactual: " ++ (show actual)
|
putStrLn $ "testing: " ++ test
|
||||||
|
putStrLn $ if actual == expected then "pass" else "failure\n" ++ "\nexpected:" ++ (show expected) ++ "\nactual: " ++ (show actual)
|
||||||
|
|||||||
@ -14,7 +14,9 @@ build-type: Simple
|
|||||||
homepage: http://github.com/gregwebs/haskell-xss-sanitize
|
homepage: http://github.com/gregwebs/haskell-xss-sanitize
|
||||||
|
|
||||||
library
|
library
|
||||||
build-depends: tagsoup >= 0.11
|
build-depends: base == 4.*, containers,
|
||||||
|
tagsoup >= 0.11, utf8-string >= 0.3, network >= 2
|
||||||
|
|
||||||
exposed-modules: Text.HTML.SanitizeXSS
|
exposed-modules: Text.HTML.SanitizeXSS
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user