check invalid unicode characters (0xd800 - 0xdfff, 0xfffe, 0xffff)

This commit is contained in:
honfika@gmail.com
2016-03-11 08:39:48 +01:00
parent 86236b32d6
commit 230f890165

View File

@@ -1120,7 +1120,7 @@ public class Helper {
public static boolean containsInvalidXMLCharacter(String text) {
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (!(ch > 31 || ch == 9 || ch == 10 || ch == 13)) {
if (!isCharacterValidInXml(ch)) {
return true;
}
}
@@ -1132,7 +1132,7 @@ public class Helper {
StringBuilder sb = new StringBuilder(text.length());
for (int i = 0; i < text.length(); i++) {
char ch = text.charAt(i);
if (ch > 31 || ch == 9 || ch == 10 || ch == 13) {
if (isCharacterValidInXml(ch)) {
sb.append(ch);
}
}
@@ -1140,6 +1140,12 @@ public class Helper {
return sb.toString();
}
private static boolean isCharacterValidInXml(char ch) {
return (ch > 31 && ch < 0xd800)
|| ch == 9 || ch == 10 || ch == 13
|| (ch >= 0xe000 && ch <= 0xfffd);
}
public static Shape imageToShapeOld(BufferedImage image) {
Area area = new Area();
Rectangle rectangle = new Rectangle();