Add more validation for 0 length JID components.
This commit is contained in:
parent
613323b5fb
commit
78aa5c3dfa
@ -140,7 +140,13 @@ def _validate_node(node):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if node is not None:
|
if node is not None:
|
||||||
|
if not node:
|
||||||
|
raise InvalidJID('Localpart must not be 0 bytes')
|
||||||
|
|
||||||
node = nodeprep(node)
|
node = nodeprep(node)
|
||||||
|
|
||||||
|
if not node:
|
||||||
|
raise InvalidJID('Localpart must not be 0 bytes')
|
||||||
return node
|
return node
|
||||||
except stringprep_profiles.StringPrepError:
|
except stringprep_profiles.StringPrepError:
|
||||||
raise InvalidJID('Invalid local part')
|
raise InvalidJID('Invalid local part')
|
||||||
@ -202,7 +208,7 @@ def _validate_domain(domain):
|
|||||||
domain = '.'.join(domain_parts)
|
domain = '.'.join(domain_parts)
|
||||||
|
|
||||||
if not domain:
|
if not domain:
|
||||||
raise InvalidJID('Missing domain')
|
raise InvalidJID('Domain must not be 0 bytes')
|
||||||
|
|
||||||
return domain
|
return domain
|
||||||
|
|
||||||
@ -216,7 +222,13 @@ def _validate_resource(resource):
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if resource is not None:
|
if resource is not None:
|
||||||
|
if not resource:
|
||||||
|
raise InvalidJID('Resource must not be 0 bytes')
|
||||||
|
|
||||||
resource = resourceprep(resource)
|
resource = resourceprep(resource)
|
||||||
|
|
||||||
|
if not resource:
|
||||||
|
raise InvalidJID('Resource must not be 0 bytes')
|
||||||
return resource
|
return resource
|
||||||
except stringprep_profiles.StringPrepError:
|
except stringprep_profiles.StringPrepError:
|
||||||
raise InvalidJID('Invalid resource')
|
raise InvalidJID('Invalid resource')
|
||||||
|
Loading…
Reference in New Issue
Block a user