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

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1.   protected char more() throws IOException, XmlPullParserException {  
  2.     final char codePoint  = super.more(); // note - this does NOT return a codepoint now, but simply a (single byte) character!  
  3. 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.  
  4.         (codePoint == 0x9) ||                              
  5.         (codePoint == 0xA) ||  
  6.         (codePoint == 0xD) ||  
  7.         ((codePoint >= 0x20) && (codePoint <= 0xD7FF)) ||  
  8.         ((codePoint >= 0xE000) && (codePoint <= 0xFFFD)) ||  
  9.         ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {  
  10.     return codePoint;  
  11. }  
  12.   
  13. throw new XmlPullParserException("Illegal XML character: " + Integer.parseInt(codePoint+""16));  
  14.   }  

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

[java]  view plain copy print ? 在CODE上查看代码片 派生到我的代码片
  1.   @Override  
  2.   protected char more() throws IOException, XmlPullParserException {  
  3.     final char codePoint  = super.more(); // note - this does NOT return a codepoint now, but simply a (single byte) character!  
  4. 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.  
  5.         (codePoint == 0x9) ||                              
  6.         (codePoint == 0xA) ||  
  7.         (codePoint == 0xD) ||         
  8.         //fix some emotion  
  9.         ((codePoint >= 0x20) && (codePoint <= 0xFFFD)) ||               
  10.         ((codePoint >= 0x10000) && (codePoint <= 0x10FFFF))) {  
  11.     return codePoint;  
  12. }  
  13.   
  14. throw new XmlPullParserException("Illegal XML character: " + Integer.parseInt(codePoint+""16));  
  15.   }  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序邦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值