### Question:
WebSecurityUtils { public static String[] sanitizeString(String[] raw) { for (int i = 0; i < raw.length; i++) { raw[i] = sanitizeString(raw[i]); } return raw; }  static String[] sanitizeString(String[] raw); static String sanitizeString(String raw); static String sanitizeString(String raw, boolean allowHTML); static int[] safeParseInt(String[] dirty); static int safeParseInt(String dirty); static long safeParseLong(String dirty); static float safeParseFloat(String dirty); static double safeParseDouble(String dirty); static String sanitizeDbColumnName(String dirty); static T sanitizeBeanStringProperties(T bean, Set<String> allowHtmlFields);  }### Answer:
@Test public void testBasicSanitizeString() { String script = "<script>foo</script>"; String html = "<table>"; script = WebSecurityUtils.sanitizeString(script); html = WebSecurityUtils.sanitizeString(html); assertTrue("Script is sanitized", script.equals("&lt;&#x73;cript&gt;foo&lt;/&#x73;cript&gt;")); assertTrue("Html is sanitized", html.equals("&lt;table&gt;")); }
@Test public void testHTMLallowedSanitizeString() { String script = "<script>foo</script>"; String html = "<table>"; script = WebSecurityUtils.sanitizeString(script, true); html = WebSecurityUtils.sanitizeString(html, true); assertTrue("Script is sanitized with HTML allowed", script.equals("<&#x73;cript>foo</&#x73;cript>")); assertTrue("HtmlTable is sanitized with HTML allowed, so unchanged", html.equals("<table>")); }