Closed Bug 955129 Opened 10 years ago Closed 10 years ago

XMPP should strip whitespace around JID

Categories

(Chat Core :: XMPP, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bugzilla, Assigned: Mook)

Details

Attachments

(1 file, 1 obsolete file)

*** Original post on bio 1701 by Mook <mook.moz+bugs.instantbird AT gmail.com> at 2012-09-19 02:33:00 UTC ***

*** Due to BzAPI limitations, the initial description is in comment 1 ***
*** Original post on bio 1701 as attmnt 1906 by mook.moz+bugs.instantbird AT gmail.com at 2012-09-19 02:33:00 UTC ***

This was reproduced on Instantbird 1.2 on Windows; haven't tried trunk, but clokep told me to file, so blame him :p

STR:
1. Have a XMPP account (I used a GTalk one)
2. Add a buddy, but accidentally have spaces before/after the ID

Expected results:
Buddy gets added

Actual results:
Nothing seems to happen; error console reports something about "received presence stanza for unknown buddy" (and the buddy JID given has the spaces in it)
Attachment #8353664 - Flags: review?
*** Original post on bio 1701 at 2012-09-19 09:49:30 UTC ***

Comment on attachment 8353664 [details] [diff] [review] (bio-attmnt 1906)
Trim whitespace. Also make the slash thing neater, while I'm at it.

>   _normalizeJID: function(aJID) {
>-    let slashIndex = aJID.indexOf("/");
>-    if (slashIndex != -1)
>-      aJID = aJID.substr(0, slashIndex);
>-    return aJID.toLowerCase();
>+    let jid = aJID.trim();
>+    jid = jid.split("/", 1)[0]; // up to first slash
>+    return jid.toLowerCase();
>   },

Why not:
  _normalizeJID: function(aJID)
    aJID.trim().split("/", 1)[0].toLowerCase(),

(or maybe even without the line break if it fits on 80 columns without it)
Comment on attachment 8353664 [details] [diff] [review]
Trim whitespace. Also make the slash thing neater, while I'm at it.

*** Original change on bio 1701 attmnt 1906 at 2012-09-19 17:09:51 UTC ***

r- as I expect an updated version before the check-in.
Attachment #8353664 - Flags: review-
*** Original post on bio 1701 as attmnt 1907 by mook.moz+bugs.instantbird AT gmail.com at 2012-09-20 02:54:00 UTC ***

Still on multiple lines, because I wanted to sneak that comment in.
Attachment #8353665 - Flags: review?(florian)
Comment on attachment 8353664 [details] [diff] [review]
Trim whitespace. Also make the slash thing neater, while I'm at it.

*** Original change on bio 1701 attmnt 1906 by mook.moz+bugs.instantbird AT gmail.com at 2012-09-20 02:54:44 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8353664 - Attachment is obsolete: true
Attachment #8353664 - Flags: review?
Comment on attachment 8353665 [details] [diff] [review]
now in one expression

*** Original change on bio 1701 attmnt 1907 at 2012-09-21 22:18:57 UTC was without comment, so any subsequent comment numbers will be shifted ***
Attachment #8353665 - Flags: review?(florian) → review+
*** Original post on bio 1701 at 2012-09-21 22:20:51 UTC ***

https://hg.instantbird.org/instantbird/rev/37d88b32d50e
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → 1.3
Assignee: bugzilla → mook.moz+mozbz
You need to log in before you can comment on or make changes to this bug.