Not logged in. · Lost password · Register
Forum: agsXMPP RSS
Avatar
tjabber #1
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Subject: MyJID off when username contains @ sign
Our user names contain @ signs because they are also email addresses. In my code I make use of XmppClientConnection.MyJID and I think when the user name contains an @ some double encoding is going on.

In the LogOn method I do this:
     mClientCon.Username = mConnectionInfo.Uri;

Which does an escape on the @ sign ( string tmpUser = Jid.EscapeNode(value);).

When the connection is opened this code:

       Console.WriteLine("LogOn: myfulljid={0} bare={1} user={2} server={3} resource={4}",
                mClientCon.MyJID.ToString(), mClientCon.MyJID.Bare.ToString(),
                mClientCon.MyJID.User, mClientCon.MyJID.Server, mClientCon.MyJID.Resource);

prints:

LogOn: myfulljid=pascal\5c40XX.com@hostname/XX bare=pascal\5c40XX.com@hostname user=pascal\5c40XX.com server=hostname resource=XX

The MyJID code also does encoding so it's double encoding which causes later errors.

Any thoughts on how to fix this?

thanks
Avatar
Alex #2
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by tjabber:
Our user names contain @ signs because they are also email addresses. In my code I make use of XmppClientConnection.MyJID and I think when the user name contains an @ some double encoding is going on.
why are you not using the email adress as jid and running the xmpp server on the email domain?

Quote by tjabber:
In the LogOn method I do this:
     mClientCon.Username = mConnectionInfo.Uri;

Which does an escape on the @ sign ( string tmpUser = Jid.EscapeNode(value);).

When the connection is opened this code:

       Console.WriteLine("LogOn: myfulljid={0} bare={1} user={2} server={3} resource={4}",
                mClientCon.MyJID.ToString(), mClientCon.MyJID.Bare.ToString(),
                mClientCon.MyJID.User, mClientCon.MyJID.Server, mClientCon.MyJID.Resource);

prints:

LogOn: myfulljid=pascal\5c40XX.com@hostname/XX bare=pascal\5c40XX.com@hostname user=pascal\5c40XX.com server=hostname resource=XX

The MyJID code also does encoding so it's double encoding which causes later errors.

Any thoughts on how to fix this?
I look at this and come back to you.

Alex
Avatar
Alex #3
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
yes the username gets escaped twice in this case. We will fix this later today.
I will let you know when the fix is available.

Alex
Avatar
Alex #4
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
fixed, new code is in SVN.

Alex
Avatar
tjabber #5
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
> why are you not using the email adress as jid and running the xmpp server on the email domain

That's just how they do things. And thanks, I'll take a look at the changes.
Avatar
tjabber #6
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
Could you please indicate which files changed? I didn't see a change in Jid.cs or XmppClientConnection.cs.
Avatar
Alex #7
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Yes these 2 files changed, make sure you have the latest revision from SVN.

Alex
Avatar
tjabber #8
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
I must have had a cached version, but the changes worked (I had to bring a few other files to compile). Thanks.

I was wondering if you expect the gets and set to be invertable? Jid.User get isn't unescaped so I have to unescape before passing it along. This may be intentional however.
Avatar
Alex #9
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by tjabber:
I was wondering if you expect the gets and set to be invertable? Jid.User get isn't unescaped so I have to unescape before passing it along. This may be intentional however.

this is by intention. If we unescape it again it will not be a valid username.

The idea is to pass the unicode code string which the end user enters to the username textbox and espace + prepare it (stringprep). So the developer and the user both don't have to bother about Jid escaping and stringprep.

Alex
Avatar
tjabber #10
Member since Feb 2008 · 42 posts
Group memberships: Members
Show profile · Link to this post
The developer does have to escape though every time the User property is displayed in a client. In the Spark client escaping is handled inconsistently. They show a \40 in the chat room, which looks a little strange.
Avatar
Alex #11
Member since Feb 2003 · 4449 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Spark shows the correct Jid, and the Jid must be escaped. If you unescape it its not a valid Jid anymore.
While its possible to revert escaping it's not possible to revert stringprep.

So if the user enters the jid:
wettern daß@ag-software.de

it gets converted to:
wetten\20dass@ag-software.de@example.com

the space gets escaped with \20 and the ß (german sharp s) gets replaced in stringprep with ss
stringprep works only one way, and I think so it does in all other stringprep libraries, so there is no way to convert such a Jid back if you received it over the wire.

I think a client should tell a user that a jid gets converted when invalid characters were entered.

Alex
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP RSS