diff --git a/Network/XMPP/SASL.hs b/Network/XMPP/SASL.hs index 77b9862..0f879d9 100644 --- a/Network/XMPP/SASL.hs +++ b/Network/XMPP/SASL.hs @@ -36,7 +36,9 @@ import qualified Data.ByteString.Lazy as DBL (ByteString, append, pack, fromChunks, toChunks, null) import qualified Data.ByteString.Lazy.Char8 as DBLC (append, pack, unpack) import qualified Data.List as DL - +import Data.Text (empty, singleton) +import Text.StringPrep (StringPrepProfile (..), a1, b1, c12, c21, c22, c3, c4, c5, c6, c7, c8, c9, runStringPrep) +import Data.Ranges (inRanges, ranges) data Challenge1Error = C1MultipleCriticalAttributes | C1NotAllParametersPresent | @@ -216,3 +218,11 @@ stripQuotations :: String -> String stripQuotations "" = "" stripQuotations s | (head s == '"') && (last s == '"') = tail $ init s | otherwise = s + + +saslprepProfile :: StringPrepProfile + +saslprepProfile = Profile { maps = [\ char -> if char `inRanges` (ranges c12) then singleton '\x0020' else empty, b1] + , shouldNormalize = True + , prohibited = [a1] ++ [c12, c21, c22, c3, c4, c5, c6, c7, c8, c9] + , shouldCheckBidi = True } diff --git a/pontarius-xmpp.cabal b/pontarius-xmpp.cabal index 17b1821..4b3d76e 100644 --- a/pontarius-xmpp.cabal +++ b/pontarius-xmpp.cabal @@ -32,7 +32,7 @@ Library text, transformers, bytestring, binary, random, xml-enumerator, tls, tls-extra, containers, mtl, text-icu, stringprep, idna2008 ==0.0.1.0, asn1-data, cryptohash, - time, certificate + time, certificate, ranges -- Other-Modules: -- HS-Source-Dirs: -- Extensions: