public
Created

Haskell test

  • Download Gist
gistfile1.hs
Haskell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.