我正在开发 XMPP 客户端,并且在发送/接收消息时遇到问题Strophe http://strophe.im/(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>
预先感谢您的任何帮助。
Edit:
出站时,Strope 似乎是双重编码。当我打字时
I'm
它正在发送
<body>I&apos;m</body>
入站,它似乎没有正确处理 CDATA。任何指导或想法表示赞赏。
好的,基于
https://github.com/metajack/stropejs/issues/54 https://github.com/metajack/strophejs/issues/54
https://github.com/metajack/stropejs/pull/59 https://github.com/metajack/strophejs/pull/59
您应该删除文本节点的转义。打开 strope.js 文件的非最小化版本和注释行 #846
//text = Strophe.xmlescape(text);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)