ScriptUtils { public static String escapeHtml(String string) { if (string == null) { return null; } else { return StringEscapeUtils.escapeHtml(string).replace("'", "&apos;").replace("&quot;", "\\u0022"); } }  static String translateValue(Object value); static String toJSON(Map<String, String> map); static String escapeJSONString(String jsonString); static String convertToJsValue(Map<String, String> stringMap); static String convertToJsValue(String value); static String escapeName(String name); static String convertStringListToJsArray(List<String> list); static String escapeHtml(String string); static List<String> escapeHtml(List<String> strings); static String appendScript(String script, String appendScript); static String buildFunctionCall(String functionName, Object... arguments); static String buildEventHandlerScript(String id, String eventName, String eventScript);  }
@Test public void testEscapeHtml() throws Exception { assertEquals("wasn&apos;t", ScriptUtils.escapeHtml("wasn't")); assertEquals("\\u0022wasn&apos;t\\u0022", ScriptUtils.escapeHtml("\"wasn't\"")); }
@Test public void testEscapeHtmlStringList() { String[] escaped = {"wasn&apos;t", "\\u0022wasn&apos;t\\u0022"}; String[] unEscaped = {"wasn't", "\"wasn't\""}; assertEquals(Arrays.asList(escaped), ScriptUtils.escapeHtml(Arrays.asList(unEscaped))); List<String> nullList = null; assertNull(ScriptUtils.escapeHtml(nullList)); List<String> emptyList = Collections.emptyList(); assertEquals(emptyList, ScriptUtils.escapeHtml(emptyList)); }