Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Link Mauve
python-nbxmpp
Commits
f6470785
Commit
f6470785
authored
Apr 18, 2020
by
Philipp Hörist
Browse files
Use IDNA2008 for domain validation
parent
442eae7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
f6470785
...
...
@@ -9,6 +9,7 @@
-
GLib >= 2.60
-
libsoup
-
precis-i18n
-
idna
## Features
...
...
nbxmpp/protocol.py
View file @
f6470785
...
...
@@ -22,9 +22,8 @@ import time
import
hashlib
import
socket
import
functools
import
stringprep
import
idna
from
base64
import
b64encode
from
encodings
import
idna
from
precis_i18n
import
get_profile
from
nbxmpp.simplexml
import
Node
...
...
@@ -789,6 +788,9 @@ def validate_resourcepart(resourcepart):
@
functools
.
lru_cache
(
maxsize
=
4096
)
def
validate_domainpart
(
domainpart
):
if
not
domainpart
:
raise
DomainpartByteLimit
# Check if this is a IPV4 address
try
:
socket
.
inet_aton
(
domainpart
)
...
...
@@ -804,27 +806,20 @@ def validate_domainpart(domainpart):
except
Exception
:
pass
if
not
domainpart
or
len
(
domainpart
.
encode
())
>
1023
:
raise
DomainpartByteLimit
if
domainpart
.
endswith
(
'.'
):
# RFC7622, 3.2
domainpart
=
domainpart
[:
-
1
]
try
:
new_labels
=
[]
for
label
in
idna
.
dots
.
split
(
domainpart
):
new_label
=
idna
.
nameprep
(
label
)
# Check unassigned
if
any
(
stringprep
.
in_table_a1
(
x
)
for
x
in
new_label
):
raise
DomainpartNotAllowedChar
new_labels
.
append
(
new_label
)
return
"."
.
join
(
new_labels
)
domainpart
=
idna
.
encode
(
domainpart
)
except
Exception
:
raise
DomainpartNotAllowedChar
length
=
len
(
domainpart
)
if
length
==
0
or
length
>
1023
:
raise
DomainpartByteLimit
return
domainpart
.
decode
()
class
JID
:
"""
...
...
setup.cfg
View file @
f6470785
...
...
@@ -15,6 +15,7 @@ python_requires = >=3.7
packages = find:
install_requires =
precis-i18n>=1.0.0
idna
[options.packages.find]
exclude =
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment