summaryrefslogtreecommitdiff
path: root/sleekxmpp/thirdparty/suelta/saslprep.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-05-14 23:12:54 -0700
committerLance Stout <lancestout@gmail.com>2012-05-14 23:12:54 -0700
commitf5beac2afafeab1f1a788d1409b61834b124469c (patch)
tree98a8a4ee16a4fc3d64422f506904b12d8ada2c67 /sleekxmpp/thirdparty/suelta/saslprep.py
parent8a23f28dfa3ac6b97d35cb81bb071cd2802271e8 (diff)
downloadslixmpp-f5beac2afafeab1f1a788d1409b61834b124469c.tar.gz
slixmpp-f5beac2afafeab1f1a788d1409b61834b124469c.tar.bz2
slixmpp-f5beac2afafeab1f1a788d1409b61834b124469c.tar.xz
slixmpp-f5beac2afafeab1f1a788d1409b61834b124469c.zip
Use SASLPrepFailure as the exception name instead of UnicodeError.
Diffstat (limited to 'sleekxmpp/thirdparty/suelta/saslprep.py')
-rw-r--r--sleekxmpp/thirdparty/suelta/saslprep.py31
1 files changed, 17 insertions, 14 deletions
diff --git a/sleekxmpp/thirdparty/suelta/saslprep.py b/sleekxmpp/thirdparty/suelta/saslprep.py
index 8022e1cd..0e72fcb1 100644
--- a/sleekxmpp/thirdparty/suelta/saslprep.py
+++ b/sleekxmpp/thirdparty/suelta/saslprep.py
@@ -5,6 +5,9 @@ import stringprep
import unicodedata
+from sleekxmpp.thirdparty.suelta.exceptions import SASLPrepFailure
+
+
def saslprep(text, strict=True):
"""
Return a processed version of the given string, using the SASLPrep
@@ -41,38 +44,38 @@ def saslprep(text, strict=True):
if text:
first_is_randal = stringprep.in_table_d1(text[0])
if first_is_randal and not stringprep.in_table_d1(text[-1]):
- raise UnicodeError('Section 6.3 [end]')
+ raise SASLPrepFailure('Section 6.3 [end]')
# Check for prohibited characters
for x in range(len(text)):
if strict and stringprep.in_table_a1(text[x]):
- raise UnicodeError('Unassigned Codepoint')
+ raise SASLPrepFailure('Unassigned Codepoint')
if stringprep.in_table_c12(text[x]):
- raise UnicodeError('In table C.1.2')
+ raise SASLPrepFailure('In table C.1.2')
if stringprep.in_table_c21(text[x]):
- raise UnicodeError('In table C.2.1')
+ raise SASLPrepFailure('In table C.2.1')
if stringprep.in_table_c22(text[x]):
- raise UnicodeError('In table C.2.2')
+ raise SASLPrepFailure('In table C.2.2')
if stringprep.in_table_c3(text[x]):
- raise UnicodeError('In table C.3')
+ raise SASLPrepFailure('In table C.3')
if stringprep.in_table_c4(text[x]):
- raise UnicodeError('In table C.4')
+ raise SASLPrepFailure('In table C.4')
if stringprep.in_table_c5(text[x]):
- raise UnicodeError('In table C.5')
+ raise SASLPrepFailure('In table C.5')
if stringprep.in_table_c6(text[x]):
- raise UnicodeError('In table C.6')
+ raise SASLPrepFailure('In table C.6')
if stringprep.in_table_c7(text[x]):
- raise UnicodeError('In table C.7')
+ raise SASLPrepFailure('In table C.7')
if stringprep.in_table_c8(text[x]):
- raise UnicodeError('In table C.8')
+ raise SASLPrepFailure('In table C.8')
if stringprep.in_table_c9(text[x]):
- raise UnicodeError('In table C.9')
+ raise SASLPrepFailure('In table C.9')
if x:
if first_is_randal and stringprep.in_table_d2(text[x]):
- raise UnicodeError('Section 6.2')
+ raise SASLPrepFailure('Section 6.2')
if not first_is_randal and \
x != len(text) - 1 and \
stringprep.in_table_d1(text[x]):
- raise UnicodeError('Section 6.3')
+ raise SASLPrepFailure('Section 6.3')
return text