Filter out invalid XML characters below 0x20 in encodeXml().

This commit is contained in:
hns 2002-09-13 15:47:27 +00:00
parent 3d6da645c5
commit abd0b867b3

View file

@ -526,7 +526,14 @@ public final class HtmlEncoder {
ret.append ("&");
break;
default:
ret.append (c);
if (c < 0x20) {
// sort out invalid XML characters below 0x20 - all but 0x9, 0xA and 0xD.
// The trick is an adaption of java.lang.Character.isSpace().
if (((((1L << 0x9) | (1L << 0xA) | (1L << 0xD)) >> ch) & 1L) != 0)
ret.append (c);
} else {
ret.append (c);
}
}
}
}