Double-encoding of Builder Nodes?

32 views
Skip to first unread message

nkeeney

unread,
Oct 11, 2012, 2:45:03 PM10/11/12
to str...@googlegroups.com
When I append a text node to a $msg Builder, I'm seeing the text content come out double html-encoded.

The code:
var text = "dog's";
var reply = $msg({to: target, from: connection.jid, type: 'chat'});
reply.c('body').t(text);
connection.send(reply.tree());
log('I sent ' + target + ': ' + text);
log('I sent as: ' + reply.toString());

Gives the following output:

11:39:42.956 BOSH LOG: I sent associat...@onstate.net/proxy: dog's
11:39:42.956 BOSH LOG: I sent as: <message type='chat' xmlns='jabber:client' to='associat...@onstate.net/proxy' from='ostes...@onstate.net/TTADEmbed'><body>dog&amp;apos;s</body></message>

I was expecting to see <body>dog&amp;s</body>

Is this intended?

Thanks!
-Nathan

nkeeney

unread,
Oct 11, 2012, 6:56:55 PM10/11/12
to str...@googlegroups.com
Update: I looked a bit into the code and I realize that toString() serializes the Builder tree and calls xmlescape() on text nodes, which pollutes the log. However, the above request goes out on the wire like this (wireshark'd):
<body rid='3673562386' xmlns='http://jabber.org/protocol/httpbind' sid='40387859f41ac28deec1d6876afa71bf4a27c8cf'><message type='chat' xmlns='jabber:client' to='associat...@onstate.net/proxy' from='ostes...@onstate.net/TTADEmbed'><body>dog&amp;apos;s</body></message></body>

Why are text nodes getting double-escaped?
Thanks!
-Nathan

On Thursday, October 11, 2012 11:45:04 AM UTC-7, nkeeney wrote:
When I append a text node to a $msg Builder, I'm seeing the text content come out double html-encoded.

The code:
var text = "dog's";
var reply = $msg({to: target, from: connection.jid, type: 'chat'});
reply.c('body').t(text);
connection.send(reply.tree());
log('I sent ' + target + ': ' + text);
log('I sent as: ' + reply.toString());

Gives the following output:

11:39:42.956 BOSH LOG: I sent associat...@onstate.net/proxy: dog's
11:39:42.956 BOSH LOG: I sent as: <message type='chat' xmlns='jabber:client' to='associate.proxy.1@onstate.net/proxy' from='ostes...@onstate.net/TTADEmbed'><body>dog&amp;apos;s</body></message>

Jack Moffitt

unread,
Mar 29, 2013, 10:57:56 AM3/29/13
to strophe
> Why are text nodes getting double-escaped?

This definitely seems like a bug. What browser are you using? Perhaps
some browsers escape the text when creating the DOM node?

jack.

Matthew Wild

unread,
Mar 29, 2013, 11:11:10 AM3/29/13
to str...@googlegroups.com
On 11 October 2012 23:56, nkeeney <nke...@on-state.com> wrote:
> Update: I looked a bit into the code and I realize that toString()
> serializes the Builder tree and calls xmlescape() on text nodes, which
> pollutes the log. However, the above request goes out on the wire like this
> (wireshark'd):
> <body rid='3673562386' xmlns='http://jabber.org/protocol/httpbind'
> sid='40387859f41ac28deec1d6876afa71bf4a27c8cf'><message type='chat'
> xmlns='jabber:client' to='associat...@onstate.net/proxy'
> from='ostes...@onstate.net/TTADEmbed'><body>dog&amp;apos;s</body></message></body>
>
> Why are text nodes getting double-escaped?

I haven't bumped into the issue in a while, but it's been a while s -
is it related perhaps to this bug?:
https://github.com/metajack/strophejs/issues/54 (closed, but I'm not
sure whether the fix is in the last release)

Regards,
Matthew

Daniel Dormont

unread,
Mar 29, 2013, 11:05:49 AM3/29/13
to str...@googlegroups.com
IIRC an older version of Strophe used to do this, there was a call to
xmlescape in the xmlTextNode function. But that's gone now.
> --
> You received this message because you are subscribed to the Google Groups "Strophe" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to strophe+u...@googlegroups.com.
> To post to this group, send email to str...@googlegroups.com.
> Visit this group at http://groups.google.com/group/strophe?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
Reply all
Reply to author
Forward
0 new messages