Last Comment Bug 786684 - JS error (TypeError: match[1] is undefined) when parsing a JID without a node part.
: JS error (TypeError: match[1] is undefined) when parsing a JID without a node...
Status: RESOLVED FIXED
:
Product: Thunderbird
Classification: Client Software
Component: Instant Messaging (show other bugs)
: 15 Branch
: All All
: -- normal with 2 votes (vote)
: Thunderbird 18.0
Assigned To: Florian Quèze [:florian] [:flo]
:
Mentors:
Depends on:
Blocks: 795959
  Show dependency treegraph
 
Reported: 2012-08-29 08:14 PDT by Igor Mackeev
Modified: 2012-10-05 11:19 PDT (History)
9 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
fixed


Attachments
Patch (no string change) (912 bytes, patch)
2012-10-01 07:27 PDT, Florian Quèze [:florian] [:flo]
clokep: review+
standard8: approval‑comm‑aurora+
Details | Diff | Review
Patch (with better error message) (3.17 KB, patch)
2012-10-01 07:28 PDT, Florian Quèze [:florian] [:flo]
clokep: review+
Details | Diff | Review

Description Igor Mackeev 2012-08-29 08:14:42 PDT
When I try to connect to the xmpp server talk37.ru, Thunderbird won't connect to the server with the following error:
Timestamp: 8/29/2012 17:33:26
Error: NS_ERROR_XPC_JS_THREW_JS_OBJECT: 'TypeError: match[1] is undefined' when calling method: [prplIAccount::connect]
Source File: resource:///components/imAccounts.js
Line: 620
Comment 1 didierg-linux 2012-08-29 08:28:58 PDT
Same problem: unable to connect to a Beehive server using XMPP protocole.

Pidgin works fine on same server with same credentials.
Comment 2 Florian Quèze [:florian] [:flo] 2012-08-29 10:18:05 PDT
(In reply to Igor Mackeev from comment #0)
> When I try to connect to the xmpp server talk37.ru, Thunderbird won't
> connect to the server with the following error:
> Timestamp: 8/29/2012 17:33:26
> Error: NS_ERROR_XPC_JS_THREW_JS_OBJECT: 'TypeError: match[1] is undefined'
> when calling method: [prplIAccount::connect]
> Source File: resource:///components/imAccounts.js
> Line: 620

The error seems to be from http://hg.mozilla.org/comm-central/annotate/a38652ab6c4d/chat/protocols/xmpp/xmpp.jsm#l952 so likely a regression from http://hg.mozilla.org/comm-central/rev/b162ce0f8d14

Have you entered a username before the hostname when you configured your xmpp account?

What does the name of your XMPP account look like in the "Show Accounts" dialog of the Chat tab?
Comment 3 Florian Quèze [:florian] [:flo] 2012-08-29 10:19:55 PDT
(In reply to didierg-linux from comment #1)
> Same problem: unable to connect to a Beehive server using XMPP protocole.
> 
> Pidgin works fine on same server with same credentials.

Do you also see the exact error that's been pasted by Igor? If not, the problem you have is not the same.
Comment 4 Aurélio A. Heckert 2012-08-29 12:04:20 PDT
I get the same error with Thunderbird 15.0 in a GNU/Linux installation.

I'm trying to connect to jabber.org (and that works for Empathy).

Hora: 29-08-2012 15:50:08
Erro: NS_ERROR_XPC_JS_THREW_JS_OBJECT: 'TypeError: match[1] is undefined' when calling method: [prplIAccount::connect]
Arquivo-fonte: resource:///components/imAccounts.js
Linha: 620
Comment 5 didierg-linux 2012-08-29 15:13:46 PDT
After more tests, it appears it is necessary to provide full qualified username in Thunderbird: username@domainname

In Pidgin, username without domainename is enough.

This problem is now fixed for me.
Comment 6 Igor Mackeev 2012-08-29 22:50:58 PDT
(In reply to Florian Quèze [:florian] [:flo] from comment #2)
> 
> Have you entered a username before the hostname when you configured your
> xmpp account?
> 
> What does the name of your XMPP account look like in the "Show Accounts"
> dialog of the Chat tab?

I tried both ways: just username and username@talk37.ru (that's what I see in "Show Accounts", respectively)

In the first case, it throws the above error.
In the second case, I get no error (in Error Console), but there is a message: Error. The sever closed the connection...
Comment 7 Paul Black 2012-08-30 05:14:13 PDT
Getting some similar issues with an in-house instance of OpenFire.

If I use just "paul.black" as the username, Thunderbird doesn't try to connect.

If I use "paul.black@<host>", it connects but after doing some SSL stuff says "Server closed the connection". Wireshark shows that Thunderbird initiated the closing of the connection.

The SSL certificate for the server is unsigned so perhaps this might be the problem. Adding the cert to Thunderbird doesn't seem to have an effect.

I then used "socat" to remove the SSL interactions. The last response received from the server is some XML starting "<success xmlns...." before Thunderbird disconnects. The message from Thunderbird is "authentication failure". The KDE Instant Messaging client proceeds beyond this point.
Comment 8 Florian Quèze [:florian] [:flo] 2012-08-30 05:29:11 PDT
(In reply to Paul Black from comment #7)
> Getting some similar issues with an in-house instance of OpenFire.
> 
> If I use just "paul.black" as the username, Thunderbird doesn't try to
> connect.

The hostname should look like an email address.

> If I use "paul.black@<host>", it connects but after doing some SSL stuff
> says "Server closed the connection". Wireshark shows that Thunderbird
> initiated the closing of the connection.
> 
> The SSL certificate for the server is unsigned so perhaps this might be the
> problem. Adding the cert to Thunderbird doesn't seem to have an effect.

You need to add the certificate *and* trust it (the certificate UI is a bit confusing). 


> I then used "socat" to remove the SSL interactions. The last response
> received from the server is some XML starting "<success xmlns...." before
> Thunderbird disconnects. The message from Thunderbird is "authentication
> failure".

Do you have a log of these interactions? If so, could you please send it to me? (florian@mozilla.com)

Was there any error in the Error Console before the "authentication failure" message appeared?
Comment 9 Laurent Bauvens 2012-09-06 02:34:17 PDT
(In reply to Paul Black from comment #7)
I experience the same behaviour Paul reports with "UID@server.domain" instead of simply "UID".

Error console displays:
Erreur : [Exception... "Component returned failure code: 0x80520015 (NS_ERROR_FILE_ACCESS_DENIED) [nsIPrefService.savePrefFile]"  nsresult: "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)"  location: "JS frame :: resource:///components/imAccounts.js :: <TOP_LEVEL> :: line 41"  data: no]
Fichier Source : resource:///components/imAccounts.js
Ligne : 41

The IM connexion window displays "Error: the server closed the connexion"

Our intranet jabberd uses encryption and IM clients like Pidgin and Spark work fine against it.
Comment 10 Florian Quèze [:florian] [:flo] 2012-09-06 02:38:35 PDT
(In reply to Laurent Bauvens from comment #9)
> (In reply to Paul Black from comment #7)
> I experience the same behaviour Paul reports with "UID@server.domain"
> instead of simply "UID".
> 
> Error console displays:
> Erreur : [Exception... "Component returned failure code: 0x80520015
> (NS_ERROR_FILE_ACCESS_DENIED) [nsIPrefService.savePrefFile]"  nsresult:
> "0x80520015 (NS_ERROR_FILE_ACCESS_DENIED)"  location: "JS frame ::
> resource:///components/imAccounts.js :: <TOP_LEVEL> :: line 41"  data: no]
> Fichier Source : resource:///components/imAccounts.js
> Ligne : 41

This error message seems to indicate that Thunderbird can't write to your profile folder.
Comment 11 Florian Quèze [:florian] [:flo] 2012-10-01 07:25:13 PDT
(In reply to Igor Mackeev from comment #0)
> When I try to connect to the xmpp server talk37.ru, Thunderbird won't
> connect to the server with the following error:
> Timestamp: 8/29/2012 17:33:26
> Error: NS_ERROR_XPC_JS_THREW_JS_OBJECT: 'TypeError: match[1] is undefined'
> when calling method: [prplIAccount::connect]
> Source File: resource:///components/imAccounts.js
> Line: 620

I'm rephrasing the summary of this bug to only cover this JS error that happens when attempting to connect an XMPP account with a username that doesn't contain the '@' character.

It's not completely clear to me what we should do in this case as the XMPP specification clearly says that the JID format is [node@]domain[/resource], so technically a username without a node part is valid, but I suspect users who write "foo" in the username box expect it to be the "node", not the domain.

In any case, I think the current JS error is the worst we can do in this case, so I'm going to fix the JID parsing to match the spec (that doesn't require string changes, so it can be fixed for Tb17).
This will make us attempt to connect, and then the server will reject us because the settings are invalid.

I tested with jabber.org:
- if I enter "testib" as username, and "jabber.org" as "Connect Server" in the advanced option, the error message in the account manager is "Error: Received unexpected data." (The jabber.org is actually sending us some invalid XML in that case, with an error message before opening the stream)
- if I use "jabber.org" as the username (ie only specifying a domain, which is valid per the XMPP spec). Then the error message I have is "Error: Not authorized (Did you enter the wrong password?)" because the server dislike what we sent.
The auth request that was actually sent used "undefined" as username.

I think if we don't have a node part on the username JID, we shouldn't even attempt to connect, so I'll attach a patch that errors out with a better error message instead of connecting with the string "undefined" as the username.
Comment 12 Florian Quèze [:florian] [:flo] 2012-10-01 07:27:07 PDT
Created attachment 666541 [details] [diff] [review]
Patch (no string change)

This only fixes the JS error.
No string change included in this patch. This will cause an error to appear in the account manager, but the error will likely be slightly confusing. I think this is better than no error at all, so I think we could take this for Thunderbird 17.
Comment 13 Florian Quèze [:florian] [:flo] 2012-10-01 07:28:57 PDT
Created attachment 666542 [details] [diff] [review]
Patch (with better error message)

With this patch (targeting comm-central only as it contains a new localizable string), an XMPP account with a username lacking the node part will refuse to connect, and the account manager will display "Error: Invalid username (your username should contain an '@' character)".
Comment 14 Florian Quèze [:florian] [:flo] 2012-10-02 06:40:37 PDT
https://hg.mozilla.org/comm-central/rev/04fbdd5e847a
Comment 15 Florian Quèze [:florian] [:flo] 2012-10-02 06:41:53 PDT
Comment on attachment 666541 [details] [diff] [review]
Patch (no string change)

[Approval Request Comment]
This bug caused a lot of confusion in support requests for misconfigured XMPP accounts, I think we will want to fix it for Thunderbird 17.
Comment 16 Florian Quèze [:florian] [:flo] 2012-10-02 06:50:53 PDT
http://hg.instantbird.org/instantbird/rev/b3f6ddac5ac0
Comment 17 Florian Quèze [:florian] [:flo] 2012-10-05 11:19:57 PDT
https://hg.mozilla.org/releases/comm-aurora/rev/db898f602809

Note You need to log in before you can comment on or make changes to this bug.