Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

parseAndCropXhtml aborts and stops all rendering of messages #321

Open
ghost opened this issue Nov 19, 2014 · 3 comments
Open

parseAndCropXhtml aborts and stops all rendering of messages #321

ghost opened this issue Nov 19, 2014 · 3 comments
Milestone

Comments

@ghost
Copy link

ghost commented Nov 19, 2014

I've got a member in a chat who uses iChat (I believe, it might be Adium) which causes problems. The following error is received in Firefox's debugging console:

function Candy.Core.Event</self.Jabber.Message() " - error - " Error: Syntax error, unrecognized expression: Bygglovsgruppen har möte, efter mötet med bygglov i går morse. Stackspårning: Sizzle</Sizzle.error@https://chat.kulturhusfestivalen.se/extlib/jquery.js:1464:2 Sizzle</Sizzle.tokenize@https://chat.kulturhusfestivalen.se/extlib/jquery.js:2079:1 Sizzle</Sizzle.select@https://chat.kulturhusfestivalen.se/extlib/jquery.js:2480:11 Sizzle@https://chat.kulturhusfestivalen.se/extlib/jquery.js:879:2 .find@https://chat.kulturhusfestivalen.se/extlib/jquery.js:2696:4 jQuery.fn.init@https://chat.kulturhusfestivalen.se/extlib/jquery.js:2816:5 jQuery@https://chat.kulturhusfestivalen.se/extlib/jquery.js:72:3 Candy.Util</self.parseAndCropXhtml@https://chat.kulturhusfestivalen.se/candy.bundle.js:692:9 Candy.View.Pane</self.Message.show@https://chat.kulturhusfestivalen.se/candy.bundle.js:4855:17 Candy.View.Observer</self.Message@https://chat.kulturhusfestivalen.se/candy.bundle.js:3032:13 jQuery.event.dispatch@https://chat.kulturhusfestivalen.se/extlib/jquery.js:4663:1 jQuery.event.add/elemData.handle@https://chat.kulturhusfestivalen.se/extlib/jquery.js:4321:1 jQuery.event.trigger@https://chat.kulturhusfestivalen.se/extlib/jquery.js:4570:5 .triggerHandler@https://chat.kulturhusfestivalen.se/extlib/jquery.js:5304:4 Candy.Core.Event</self.Jabber.Room.Message@https://chat.kulturhusfestivalen.se/candy.bundle.js:2742:21 Candy.Core.Event</self.Jabber.Message@https://chat.kulturhusfestivalen.se/candy.bundle.js:2334:17 Strophe.Handler.prototype.run@https://chat.kulturhusfestivalen.se/libs/libs.bundle.js:1619:17 Strophe.Connection.prototype._dataRecv/<@https://chat.kulturhusfestivalen.se/libs/libs.bundle.js:2470:1 Strophe.forEachChild@https://chat.kulturhusfestivalen.se/libs/libs.bundle.js:771:21 Strophe.Connection.prototype._dataRecv@https://chat.kulturhusfestivalen.se/libs/libs.bundle.js:2459:13 Strophe.Bosh.prototype._onRequestStateChange@https://chat.kulturhusfestivalen.se/libs/libs.bundle.js:3766:17 "Syntax error, unrecognized expression: Bygglovsgruppen har möte, efter mötet med bygglov i går morse."

I don't have a big selection of strings sent from that client causing the problem, but the following is one:
Bygglovsgruppen har möte, efter mötet med bygglov i går morse.
(as you can see it has unicode characters, though I'm not sure they're related)

The issue, after getting some help from that horrible error message, seems to be in candy.bundle.js for the Candy.View.Pane.Message.show method when it is supplied a (probably incorrect then) xhtmlMessage parameter.

The function is at about line 4850 in my copy of the bundled JS and it is the function called here:
if (xhtmlMessage) { xhtmlMessage = Candy.Util.parseAndCropXhtml(xhtmlMessage, Candy.View.getOptions().crop.message.body); }

which looks like this:
self.parseAndCropXhtml = function(str, len) { alert(str); return $("<div/>").append(self.createHtml($(str).get(0), len)).html(); };

...I'll just publish this issue now and can fill out more info later. Does anyone else have this experience - or figure out what happens that causes the error - or should I debug some more and elaborate?

@mweibel
Copy link
Member

mweibel commented Nov 20, 2014

Hi,

this looks to me like the awesome unicode errors because of the cropping. It does most likely crop in the middle of a unicode character..
There are some libraries as far as I remember which handle unicode correctly. Will need to find them again, but maybe what I wrote here helps you already in figuring out how to fix it ;)

@Drakemor
Copy link

I got similar issue, but it was with latest candy dev code.
My solution was changing the event.js in line 863 from
var xhtmlMessage = $($('<div>').append(xhtmlChild.children('body').first().contents()).html());
to
var xhtmlMessage = $($('<div>').append(xhtmlChild.children('body').first().clone()).html());

@lkraav
Copy link
Contributor

lkraav commented Jun 15, 2015

Yes, I think I'm seeing this same thing

This message from iChat stopped rendering contents for the chat it was sent to + all chats rendered after it. Ouchie!

<body>interesting: https://scontent-fra3-1.xx.fbcdn.net/hphotos-xat1/v/t1.0-9/11536094_650488775082102_5200553068077727363_n.png?oh=39ff876d7a317a685b329d5acfc919b3&amp;oe=55E6A086</body>

@benlangfeld benlangfeld modified the milestone: v2.2.0 Aug 12, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants