From e7be002c5ec6b71505746044c4f5c6aa3546122b Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Mon, 11 Jun 2012 20:18:44 +0200 Subject: [PATCH] add space-folding to Sasl/StringPrep --- source/Network/Xmpp/Sasl/StringPrep.hs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/Network/Xmpp/Sasl/StringPrep.hs b/source/Network/Xmpp/Sasl/StringPrep.hs index 27de3d6..0f20298 100644 --- a/source/Network/Xmpp/Sasl/StringPrep.hs +++ b/source/Network/Xmpp/Sasl/StringPrep.hs @@ -1,9 +1,19 @@ +{-# LANGUAGE OverloadedStrings #-} module Network.Xmpp.Sasl.StringPrep where import Text.StringPrep +import qualified Data.Set as Set +import Data.Text(singleton) + +nonAsciiSpaces = Set.fromList [ '\x00A0','\x1680','\x2000','\x2001','\x2002' + , '\x2003', '\x2004','\x2005','\x2006','\x2007' + , '\x2008','\x2009', '\x200A','\x200B' ,'\x202F' + , '\x205F','\x3000'] + +toSpace x = if x `Set.member` nonAsciiSpaces then " " else singleton x saslPrepQuery = Profile - [b1] + [b1, toSpace] True [ c12 , c21 @@ -19,7 +29,7 @@ saslPrepQuery = Profile True saslPrepStore = Profile - [b1] + [b1, toSpace] True [ a1 , c12