candy-chat / candy

JavaScript-based multi-user chat client for XMPP.
http://candy-chat.github.io/candy
MIT License
1.32k stars 370 forks source link

Bug: Any non-plaintext content pasted into chat from Pidgin appears as [object Object] #444

Open marcteale opened 8 years ago

marcteale commented 8 years ago

I have an OpenFire chat server with a Candy interface. When pasting links (or any other non-plaintext content) into the Pidgin window, they appear as [object Object] in the Candy chat window. Links pasted into Candy function normally.

In the screenshots below, the message at 4:28:08 was pasted into the Candy chat window, and is formatted correctly. The message at 4:28:18 was pasted into the Pidgin chat windows, and appears in Candy as [object Object]. The preceding text is also removed.

bug_report1

bug_report2

This error exists in Firefox, Chrome, IE, and Edge.

Server setup: OpenFire Server 3.10.3 CentOS 7.1.1503 Candy 2.1.0 Pidgin 2.10.11 Apache HTTPD 2.4.6-31.el7.centos.1.x86_64

benlangfeld commented 8 years ago

Would you please provide debug logs from your browser console so that I can see what message Candy actually received?

marcteale commented 8 years ago

Let me know if you need any more logs. Thanks.

[Strophe][DEBUG]: request id 13.1 state changed to 2
candy.min.js (line 1)
[Strophe][DEBUG]: request id 13.1 state changed to 3
candy.min.js (line 1)
[Strophe][DEBUG]: request id 13.1 state changed to 4
candy.min.js (line 1)
[Strophe][DEBUG]: removing request
candy.min.js (line 1)
[Strophe][DEBUG]: _throttledRequestHandler called with 0 requests
candy.min.js (line 1)
[Strophe][DEBUG]: request id 13 should now be removed
candy.min.js (line 1)
[Strophe][DEBUG]: request id 13.1 got 200
candy.min.js (line 1)
[Strophe][INFO]: _dataRecv called
candy.min.js (line 1)
RECV: <body xmlns='http://jabber.org/protocol/httpbind' ack='1318104843'><message xmlns='jabber:client' type='groupchat' id='purplec32e4bbf' to='marc@example.com/Candy' from='chat@conference.example.com/marc'><body>https://github.com</body><html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'><p><a href='https://github.com'>https://github.com</a></p></body></html></message></body>
candy.min.js (line 1)
[Jabber] Message
candy.min.js (line 1)
[Jabber:Room] Message
candy.min.js (line 1)
[Strophe][INFO]: no requests during idle cycle, sending blank request
candy.min.js (line 1)
[Strophe][DEBUG]: request id 14.0 posting
candy.min.js (line 1)
[Strophe][DEBUG]: request id 14.0 state changed to 1
dragonk1988 commented 8 years ago

After 2 hours searching. I found it under line 4676.

Cahnge: from: if (xhtmlMessage !== undefined && xhtmlMessage.length > 0) { to: if (xhtmlMessage !== undefined && xhtmlMessage.length > 1) {

it looks like openfire is set the xHTML-Message with an "blank" instet of empty.

I put a log line in the if, so i could see this: Log entry in code: Candy.Core.log("[show] renderXhtmlMessage: " + JSON.stringify(xhtmlMessage));

Result with length > 0: [show] renderXhtmlMessage: {"0":{},"length":1}

sorry for my bad English, i'm a german potato ;)

tobru commented 8 years ago

Same here:

RECV: <body xmlns:stream='http://etherx.jabber.org/streams' xmlns='http://jabber.org/protocol/httpbind' sid='HIDDEN'><message xmlns='jabber:client' type='groupchat' to='my@me.net/Candy' from='room@conference.me.net/tobru' id='purple18e1021'><body>testing webclient https://jabber.me.net/</body><html xmlns='http://jabber.org/protocol/xhtml-im'><body xmlns='http://www.w3.org/1999/xhtml'><p>testing webclient <a href='https://jabber.me.net/'>https://jabber.me.net/</a></p></body></html></message></body>
tobru commented 8 years ago

Oh, I see... When setting enableXHTML to true, then this is not an issue anymore =) One should properly read the docs before complaining

marcteale commented 8 years ago

Tested setting enableXHTML to true, seems to be working now. Thanks.

smokku commented 8 years ago

I think with enableXHTML: false we should see <body> content as usual, not [object Object]?

tjbonzo commented 8 years ago

The "enableXHTML: true" statement belongs in the view: section. Took me a bit to figure that out.

heavygale commented 8 years ago

But adding "enableXHTML: true" in the view-options results in the following error:

function Candy.Core.Event</a.Jabber.Presence()  - error -  Error: Syntax error, unrecognized expression: testuser joined the room.
Stack-Trace:
at.error@https://example.com/candy/candy/jquery.min.js:4:15710
mt@https://example.com/candy/candy/jquery.min.js:4:21596
kt@https://example.com/candy/candy/jquery.min.js:4:24325
at@https://example.com/candy/candy/jquery.min.js:4:10694
.find@https://example.com/candy/candy/jquery.min.js:5:21209
x.prototype.init@https://example.com/candy/candy/jquery.min.js:4:1142
x@https://example.com/candy/candy/jquery.min.js:4:225
Candy.Util</a.parseAndCropXhtml@https://example.com/candy/candy/candy.min.js:1:6679
Candy.View.Pane</a.Chat.onInfoMessage@https://example.com/candy/candy/candy.min.js:2:10728
Candy.View.Pane</a.Chat.infoMessage@https://example.com/candy/candy/candy.min.js:2:10553
Candy.View.Pane</a.Roster.showJoinAnimation@https://example.com/candy/candy/candy.min.js:3:3619
Candy.View.Pane</a.Roster.update@https://example.com/candy/candy/candy.min.js:3:672
Candy.View.Observer</a.Presence.update@https://example.com/candy/candy/candy.min.js:2:5246
x.event.dispatch@https://example.com/candy/candy/jquery.min.js:5:14077
x.event.add/v.handle@https://example.com/candy/candy/jquery.min.js:5:10849
x.event.trigger@https://example.com/candy/candy/jquery.min.js:5:13253
.triggerHandler@https://example.com/candy/candy/jquery.min.js:5:20849
Candy.Core.Event</a.Jabber.Room.Presence@https://example.com/candy/candy/candy.min.js:1:31021
Candy.Core.Event</a.Jabber.Presence@https://example.com/candy/candy/candy.min.js:1:26291
f.Handler.prototype.run@https://example.com/candy/candy/libs.min.js:1:15817
f.Connection.prototype._dataRecv/<@https://example.com/candy/candy/libs.min.js:1:22445
f.forEachChild@https://example.com/candy/candy/libs.min.js:1:8462
f.Connection.prototype._dataRecv@https://example.com/candy/candy/libs.min.js:1:22278
Strophe.Bosh.prototype._onRequestStateChange@https://example.com/candy/candy/libs.min.js:2:6782
 Syntax error, unrecognized expression: testuser joined the room.