@Test public void escapeHTML() { Assert.assertNull(ConsoleProxyServlet.escapeHTML(null)); Assert.assertEquals("", ConsoleProxyServlet.escapeHTML("")); Assert.assertEquals("&lt;strangevmname&gt;", ConsoleProxyServlet.escapeHTML("<strangevmname>")); Assert.assertEquals("&quot;strange&nbsp;vm&quot;", ConsoleProxyServlet.escapeHTML("\"strange vm\"")); Assert.assertEquals("Nothing-extraordinary-anyway.", ConsoleProxyServlet.escapeHTML("Nothing-extraordinary-anyway.")); }
public static final String escapeHTML(final String content) { if (content == null || content.isEmpty()) { return content; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < content.length(); i++) { final char c = content.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case ' ': sb.append("&nbsp;"); break; default: sb.append(c); break; } } return sb.toString(); }
ConsoleProxyServlet extends HttpServlet { public static final String escapeHTML(final String content) { if (content == null || content.isEmpty()) { return content; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < content.length(); i++) { final char c = content.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case ' ': sb.append("&nbsp;"); break; default: sb.append(c); break; } } return sb.toString(); } }
ConsoleProxyServlet extends HttpServlet { public static final String escapeHTML(final String content) { if (content == null || content.isEmpty()) { return content; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < content.length(); i++) { final char c = content.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case ' ': sb.append("&nbsp;"); break; default: sb.append(c); break; } } return sb.toString(); } ConsoleProxyServlet(); }
ConsoleProxyServlet extends HttpServlet { public static final String escapeHTML(final String content) { if (content == null || content.isEmpty()) { return content; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < content.length(); i++) { final char c = content.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case ' ': sb.append("&nbsp;"); break; default: sb.append(c); break; } } return sb.toString(); } ConsoleProxyServlet(); static Ternary<String, String, String> parseHostInfo(final String hostInfo); static String genAccessTicket(final String host, final String port, final String sid, final String tag); static String genAccessTicket(final String host, final String port, final String sid, final String tag, final Date normalizedHashTime); static final String escapeHTML(final String content); @Override void init(final ServletConfig config); boolean verifyUser(final Long userId); }
ConsoleProxyServlet extends HttpServlet { public static final String escapeHTML(final String content) { if (content == null || content.isEmpty()) { return content; } final StringBuilder sb = new StringBuilder(); for (int i = 0; i < content.length(); i++) { final char c = content.charAt(i); switch (c) { case '<': sb.append("&lt;"); break; case '>': sb.append("&gt;"); break; case '&': sb.append("&amp;"); break; case '"': sb.append("&quot;"); break; case ' ': sb.append("&nbsp;"); break; default: sb.append(c); break; } } return sb.toString(); } ConsoleProxyServlet(); static Ternary<String, String, String> parseHostInfo(final String hostInfo); static String genAccessTicket(final String host, final String port, final String sid, final String tag); static String genAccessTicket(final String host, final String port, final String sid, final String tag, final Date normalizedHashTime); static final String escapeHTML(final String content); @Override void init(final ServletConfig config); boolean verifyUser(final Long userId); static final Logger s_logger; }