Move and rename xmpp_stringprep.py
It is more consistent to have this code closer to the xmpp protocol handling.
This commit is contained in:
parent
3fc9c10caa
commit
5cea6334ef
|
@ -122,7 +122,7 @@ def parse_resource(resource):
|
||||||
'''Perform stringprep on resource and return it'''
|
'''Perform stringprep on resource and return it'''
|
||||||
if resource:
|
if resource:
|
||||||
try:
|
try:
|
||||||
from xmpp_stringprep import resourceprep
|
from xmpp.stringprepare import resourceprep
|
||||||
return resourceprep.prepare(unicode(resource))
|
return resourceprep.prepare(unicode(resource))
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, 'Invalid character in resource.'
|
raise InvalidFormat, 'Invalid character in resource.'
|
||||||
|
@ -134,7 +134,7 @@ def prep(user, server, resource):
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
try:
|
try:
|
||||||
from xmpp_stringprep import nodeprep
|
from xmpp.stringprepare import nodeprep
|
||||||
user = nodeprep.prepare(unicode(user))
|
user = nodeprep.prepare(unicode(user))
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in username.')
|
raise InvalidFormat, _('Invalid character in username.')
|
||||||
|
@ -145,14 +145,14 @@ def prep(user, server, resource):
|
||||||
raise InvalidFormat, _('Server address required.')
|
raise InvalidFormat, _('Server address required.')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
from xmpp_stringprep import nameprep
|
from xmpp.stringprepare import nameprep
|
||||||
server = nameprep.prepare(unicode(server))
|
server = nameprep.prepare(unicode(server))
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in hostname.')
|
raise InvalidFormat, _('Invalid character in hostname.')
|
||||||
|
|
||||||
if resource:
|
if resource:
|
||||||
try:
|
try:
|
||||||
from xmpp_stringprep import resourceprep
|
from xmpp.stringprepare import resourceprep
|
||||||
resource = resourceprep.prepare(unicode(resource))
|
resource = resourceprep.prepare(unicode(resource))
|
||||||
except UnicodeError:
|
except UnicodeError:
|
||||||
raise InvalidFormat, _('Invalid character in resource.')
|
raise InvalidFormat, _('Invalid character in resource.')
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
## src/common/xmpp_stringprep.py
|
## src/common/xmpp/stringprepare.py
|
||||||
##
|
##
|
||||||
## Copyright (C) 2001-2005 Twisted Matrix Laboratories
|
## Copyright (C) 2001-2005 Twisted Matrix Laboratories
|
||||||
## Copyright (C) 2005-2007 Yann Leboulanger <asterix AT lagaule.org>
|
## Copyright (C) 2005-2007 Yann Leboulanger <asterix AT lagaule.org>
|
Loading…
Reference in New Issue