Browse Source

implemented the saslprep stringprep profile

master
Jon Kristensen 15 years ago
parent
commit
e7a390ae0e
  1. 12
      Network/XMPP/SASL.hs
  2. 2
      pontarius-xmpp.cabal

12
Network/XMPP/SASL.hs

@ -36,7 +36,9 @@ import qualified Data.ByteString.Lazy as DBL (ByteString, append, pack,
fromChunks, toChunks, null) fromChunks, toChunks, null)
import qualified Data.ByteString.Lazy.Char8 as DBLC (append, pack, unpack) import qualified Data.ByteString.Lazy.Char8 as DBLC (append, pack, unpack)
import qualified Data.List as DL 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 | data Challenge1Error = C1MultipleCriticalAttributes |
C1NotAllParametersPresent | C1NotAllParametersPresent |
@ -216,3 +218,11 @@ stripQuotations :: String -> String
stripQuotations "" = "" stripQuotations "" = ""
stripQuotations s | (head s == '"') && (last s == '"') = tail $ init s stripQuotations s | (head s == '"') && (last s == '"') = tail $ init s
| otherwise = 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 }

2
pontarius-xmpp.cabal

@ -32,7 +32,7 @@ Library
text, transformers, bytestring, binary, random, text, transformers, bytestring, binary, random,
xml-enumerator, tls, tls-extra, containers, mtl, text-icu, xml-enumerator, tls, tls-extra, containers, mtl, text-icu,
stringprep, idna2008 ==0.0.1.0, asn1-data, cryptohash, stringprep, idna2008 ==0.0.1.0, asn1-data, cryptohash,
time, certificate time, certificate, ranges
-- Other-Modules: -- Other-Modules:
-- HS-Source-Dirs: -- HS-Source-Dirs:
-- Extensions: -- Extensions:

Loading…
Cancel
Save