解决openfire中发送某些特殊字符会断开xmpp连接的问题

本文介绍了一个关于OpenFire中对于特定表情过滤的问题及解决方案。通过对源代码进行微调,解决了因表情过滤而导致的连接断开问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    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表情的过滤导致,链接断开;因此稍微对源码做修改

    @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));
    }




文章来源于http://blog.youkuaiyun.com/newjueqi/article/details/18260197,感谢作者的分享


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值