您的位置:首页 > 运维架构

Xmpp遇到的问题:openfire中发送某些特殊字符会断开xmpp连接的问题(3)

2015-01-28 16:27 525 查看
[java] view
plaincopyprint?





protected char more() throws IOException, XmlPullParserException {

final char codePoint = super.more(); // note - this does NOT return a codepoint now, but simply a (single byte) character!

if ((codePoint == 0x0) || // 0x0 is not allowed, but flash clients insist on sending this as the very first character of a stream. We should stop allowing this codepoint after the first byte has been parsed.

(codePoint == 0x9) ||

(codePoint == 0xA) ||

(codePoint == 0xD) ||

((codePoint >= 0x20) && (codePoint <= 0xD7FF)) ||

((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) ||

((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {

return codePoint;

}



throw new XmlPullParserException("Illegal XML character: " + Integer.parseInt(codePoint+"", 16));

}

由于openfire 对emoj表情的过滤导致,链接断开;因此稍微对源码做修改

[java] view
plaincopyprint?





@Override

protected char more() throws IOException, XmlPullParserException {

final char codePoint = super.more(); // note - this does NOT return a codepoint now, but simply a (single byte) character!

if ((codePoint == 0x0) || // 0x0 is not allowed, but flash clients insist on sending this as the very first character of a stream. We should stop allowing this codepoint after the first byte has been parsed.

(codePoint == 0x9) ||

(codePoint == 0xA) ||

(codePoint == 0xD) ||

//fix some emotion

((codePoint >= 0x20) && (codePoint <= 0xFFFD)) ||

((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {

return codePoint;

}



throw new XmlPullParserException("Illegal XML character: " + Integer.parseInt(codePoint+"", 16));

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: