Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Weblate
gajim
Commits
aaa82b82
Commit
aaa82b82
authored
16 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
[thorstenp] import idna only when needed. see #4457
parent
47f34bcd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/common/helpers.py
+6
-2
6 additions, 2 deletions
src/common/helpers.py
with
6 additions
and
2 deletions
src/common/helpers.py
+
6
−
2
View file @
aaa82b82
...
...
@@ -40,12 +40,10 @@ import sha
import
base64
import
sys
from
encodings.punycode
import
punycode_encode
from
encodings
import
idna
import
gajim
from
i18n
import
Q_
from
i18n
import
ngettext
from
xmpp_stringprep
import
nodeprep
,
resourceprep
,
nameprep
import
xmpp
try
:
...
...
@@ -121,6 +119,7 @@ def parse_jid(jidstring):
def
idn_to_ascii
(
host
):
'''
convert IDN (Internationalized Domain Names) to ACE
(ASCII-compatible encoding)
'''
from
encodings
import
idna
labels
=
idna
.
dots
.
split
(
host
)
converted_labels
=
[]
for
label
in
labels
:
...
...
@@ -130,6 +129,7 @@ def idn_to_ascii(host):
def
ascii_to_idn
(
host
):
'''
convert ACE (ASCII-compatible encoding) to IDN
(Internationalized Domain Names)
'''
from
encodings
import
idna
labels
=
idna
.
dots
.
split
(
host
)
converted_labels
=
[]
for
label
in
labels
:
...
...
@@ -140,6 +140,7 @@ def parse_resource(resource):
'''
Perform stringprep on resource and return it
'''
if
resource
:
try
:
from
xmpp_stringprep
import
resourceprep
return
resourceprep
.
prepare
(
unicode
(
resource
))
except
UnicodeError
:
raise
InvalidFormat
,
'
Invalid character in resource.
'
...
...
@@ -151,6 +152,7 @@ def prep(user, server, resource):
if
user
:
try
:
from
xmpp_stringprep
import
nodeprep
user
=
nodeprep
.
prepare
(
unicode
(
user
))
except
UnicodeError
:
raise
InvalidFormat
,
_
(
'
Invalid character in username.
'
)
...
...
@@ -161,12 +163,14 @@ def prep(user, server, resource):
raise
InvalidFormat
,
_
(
'
Server address required.
'
)
else
:
try
:
from
xmpp_stringprep
import
nameprep
server
=
nameprep
.
prepare
(
unicode
(
server
))
except
UnicodeError
:
raise
InvalidFormat
,
_
(
'
Invalid character in hostname.
'
)
if
resource
:
try
:
from
xmpp_stringprep
import
resourceprep
resource
=
resourceprep
.
prepare
(
unicode
(
resource
))
except
UnicodeError
:
raise
InvalidFormat
,
_
(
'
Invalid character in resource.
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment