Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strophe character encoding issue

I am working on an XMPP client and having an issue with messages being sent/received by Strophe (javascript version).

The issue is messages that contain "special" characters. For instance, if I send:

I'm here.

An external client (i.e. iChat) will display

I&ampapos;m here.

A strophe client doesn't display anything at all.

If I send that same message from iChat to the strophe client, it displays properly.

Here is the most basic sample code I could come up with:

<html>
<head>
  <script type='text/javascript' src='strophe.min.js'></script>
  <script type='text/javascript'>
    function onConnect(status) {
        if (status == Strophe.Status.CONNECTED) {
            var message = $msg({to: CONTACT_JID, from: JID, type: 'chat'}).c('body').t("I'm here."); ;
            connection.send(message.tree());
        }
    }
    var connection = new Strophe.Connection('http://bosh.metajack.im:5280/xmpp-httpbind');
    connection.connect(JID, PASS, onConnect);
  </script>
</head>
<body></body>
</html>

Thanks in advance for any help.

Edit:

Outbound, it seems Strophe is double encoding. When I type

I'm

it is sending

<body>I&amp;apos;m</body>

Inbound, it appears to not be handling CDATA properly. Any guidance or ideas are appreciated.

like image 822
jopke Avatar asked Feb 05 '12 03:02

jopke


1 Answers

Ok, based on

https://github.com/metajack/strophejs/issues/54

https://github.com/metajack/strophejs/pull/59

you should remove escaping of the text node. Open non-minimized version of strophe.js file and comment line #846

//text = Strophe.xmlescape(text);
like image 180
Cheery Avatar answered Nov 09 '22 10:11

Cheery