Strope字符编码问题
我正在开发 XMPP 客户端,并且遇到 Strope (javascript 版本)发送/接收消息的问题。
问题是包含“特殊”字符的消息。例如,如果我发送:
我在这里。
将显示外部客户端(即 iChat)
我在这里。
strope 客户端根本不显示任何内容。
如果我将相同的消息从 iChat 发送到 strope 客户端,它会正确显示。
这是我能想到的最基本的示例代码:
<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>
提前感谢您的帮助。
编辑:
出站,似乎 Strope 是双重编码。当我打字时
我是
正在发送
<body>I&apos;m</body>
入站,它似乎没有正确处理 CDATA。任何指导或想法表示赞赏。
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&apos;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'm</body>
Inbound, it appears to not be handling CDATA properly. Any guidance or ideas are appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,基于
https://github.com/metajack/stropejs/issues/54
https://github.com/metajack/stropejs/pull/59
你应该删除文本节点的转义。打开 strope.js 文件的非最小化版本和注释行 #846
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