byte[] bufUTF16 = alt.getBytes("UTF-16");
byte[] total = new byte[buf.length+utf16bom.length+bufUTF16.length];
System.arraycopy(utf16bom, 0, total, 0, utf16bom.length);
System.arraycopy(buf, 0, total, utf16bom.length, buf.length);
System.arraycopy(bufUTF16, 0, total, utf16bom.length+buf.length, bufUTF16.length);
HTMLFilter filter = new HTMLFilter();
boolean failed = false;
FileOutputStream fos;
try {
ArrayBucket out = new ArrayBucket();
filter.readFilter(new ArrayBucket(total).getInputStream(), out.getOutputStream(), "UTF-16", null, null);
fos = new FileOutputStream("output.utf16");
fos.write(out.toByteArray());
fos.close();
failed = true;
assertFalse("Filter accepted dangerous UTF8 text with BOM as UTF16! (HTMLFilter)", true);