Skip to content

Instantly share code, notes, and snippets.

@Zert
Created November 28, 2011 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zert/1400123 to your computer and use it in GitHub Desktop.
Save Zert/1400123 to your computer and use it in GitHub Desktop.
Haskell test
module Main where
import Text.HTML.SanitizeXSS
import System.IO
import Data.Text (pack, unpack)
import Data.Binary.Get
import Data.Binary.Put
import Data.Binary
import Data.Word
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Lazy.UTF8 as BU
import Control.Monad
main = do
i <- B.hGet stdin 4
let len = runGet getWord32be i
content <- B.hGet stdin (fromIntegral len)
let sanitized = BU.fromString . unpack . sanitizeBalance . pack $ BU.toString content
let result = runPut $ putWord32be (fromIntegral $ B.length sanitized)
B.hPut stdout result
B.hPut stdout sanitized
hClose stdin
hClose stdout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment