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
effa7ced
Commit
effa7ced
authored
14 years ago
by
Yann Leboulanger
Browse files
Options
Downloads
Patches
Plain Diff
correctly prep JID: "@server" is not a valid JID
parent
0fcb1f70
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
+16
-10
16 additions, 10 deletions
src/common/helpers.py
with
16 additions
and
10 deletions
src/common/helpers.py
+
16
−
10
View file @
effa7ced
...
@@ -75,22 +75,22 @@ def decompose_jid(jidstring):
...
@@ -75,22 +75,22 @@ def decompose_jid(jidstring):
else
:
else
:
# host/resource
# host/resource
server
=
jidstring
[
0
:
res_sep
]
server
=
jidstring
[
0
:
res_sep
]
resource
=
jidstring
[
res_sep
+
1
:]
or
None
resource
=
jidstring
[
res_sep
+
1
:]
else
:
else
:
if
res_sep
==
-
1
:
if
res_sep
==
-
1
:
# user@host
# user@host
user
=
jidstring
[
0
:
user_sep
]
or
None
user
=
jidstring
[
0
:
user_sep
]
server
=
jidstring
[
user_sep
+
1
:]
server
=
jidstring
[
user_sep
+
1
:]
else
:
else
:
if
user_sep
<
res_sep
:
if
user_sep
<
res_sep
:
# user@host/resource
# user@host/resource
user
=
jidstring
[
0
:
user_sep
]
or
None
user
=
jidstring
[
0
:
user_sep
]
server
=
jidstring
[
user_sep
+
1
:
user_sep
+
(
res_sep
-
user_sep
)]
server
=
jidstring
[
user_sep
+
1
:
user_sep
+
(
res_sep
-
user_sep
)]
resource
=
jidstring
[
res_sep
+
1
:]
or
None
resource
=
jidstring
[
res_sep
+
1
:]
else
:
else
:
# server/resource (with an @ in resource)
# server/resource (with an @ in resource)
server
=
jidstring
[
0
:
res_sep
]
server
=
jidstring
[
0
:
res_sep
]
resource
=
jidstring
[
res_sep
+
1
:]
or
None
resource
=
jidstring
[
res_sep
+
1
:]
return
user
,
server
,
resource
return
user
,
server
,
resource
def
parse_jid
(
jidstring
):
def
parse_jid
(
jidstring
):
...
@@ -143,7 +143,9 @@ def prep(user, server, resource):
...
@@ -143,7 +143,9 @@ def prep(user, server, resource):
"""
"""
# This function comes from
# This function comes from
#http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
#http://svn.twistedmatrix.com/cvs/trunk/twisted/words/protocols/jabber/jid.py
if
user
:
if
user
is
not
None
:
if
len
(
user
)
<
1
or
len
(
user
)
>
1023
:
raise
InvalidFormat
,
_
(
'
Username must be between 1 and 1023 chars
'
)
try
:
try
:
from
xmpp.stringprepare
import
nodeprep
from
xmpp.stringprepare
import
nodeprep
user
=
nodeprep
.
prepare
(
unicode
(
user
))
user
=
nodeprep
.
prepare
(
unicode
(
user
))
...
@@ -152,16 +154,20 @@ def prep(user, server, resource):
...
@@ -152,16 +154,20 @@ def prep(user, server, resource):
else
:
else
:
user
=
None
user
=
None
if
not
server
:
if
server
is
not
None
:
raise
InvalidFormat
,
_
(
'
Server address required.
'
)
if
len
(
server
)
<
1
or
len
(
server
)
>
1023
:
else
:
raise
InvalidFormat
,
_
(
'
Server must be between 1 and 1023 chars
'
)
try
:
try
:
from
xmpp.stringprepare
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.
'
)
else
:
raise
InvalidFormat
,
_
(
'
Server address required.
'
)
if
resource
:
if
resource
is
not
None
:
if
len
(
resource
)
<
1
or
len
(
resource
)
>
1023
:
raise
InvalidFormat
,
_
(
'
Resource must be between 1 and 1023 chars
'
)
try
:
try
:
from
xmpp.stringprepare
import
resourceprep
from
xmpp.stringprepare
import
resourceprep
resource
=
resourceprep
.
prepare
(
unicode
(
resource
))
resource
=
resourceprep
.
prepare
(
unicode
(
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