Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
0.7
-
None
-
None
-
java1.6, windows7
Description
If message stanza contains text: "辽宁" (escape before send:"辽宁")
exception will be throw out:
Caused by: org.xml.sax.SAXParseException: For input string: "8FBD;宁"
at org.apache.vysper.xml.sax.impl.XMLParser.fatalError(XMLParser.java:499)
at org.apache.vysper.xml.sax.impl.XMLParser.parse(XMLParser.java:124)
at org.apache.vysper.xml.sax.impl.DefaultNonBlockingXMLReader.parse(DefaultNonBlockingXMLReader.java:185)
at org.apache.vysper.xml.decoder.XMPPDecoder.doDecode(XMPPDecoder.java:117)
Caused by:String org.apache.vysper.xml.sax.impl.XMLParser.unescape(String s)
private String unescape(String s) {
s = s.replace("&", "&").replace(">", ">").replace("<", "<").replace("'", "'").replace(""",
"\"");
StringBuffer sb = new StringBuffer();
Matcher matcher = UNESCAPE_UNICODE_PATTERN.matcher(s);
int end = 0;
while (matcher.find())
sb.append(s.substring(end, s.length()));
return sb.toString();
}
Replace xml predefined entities before unescape change the context of escaped strings.
For example:
Input: "辽宁"
After replace: "辽宁"
unescape use regex: Pattern.compile("\\&
#(x?)(.+);");
match:
group(1) = x
group(2) = 8FBD;宁
then Integer.valueOf(unicodeCode, base) will throw exception.
I fixed this bug, see the patch.