@Override protected String produceEscapedOutput(final Object input) { if (input == null) { return ""; } return HtmlEscape.escapeHtml4Xml(input.toString()); }
public static String html2utf8(String s) { String unescape = HtmlEscape.unescapeHtml(s); unescape = A_END_TAG.matcher(unescape).replaceAll(""); unescape = unescape.trim().replaceAll(" +", " "); return unescape; }
@Override public void configure(final Env env, final Config conf, final Binder binder) { env.xss("html", it -> HtmlEscape.escapeHtml(it, htmltype, htmllevel)) .xss("js", it -> JavaScriptEscape.escapeJavaScript(it, jstype, jslevel)) .xss("json", it -> JsonEscape.escapeJson(it, jsontype, jsonlevel)) .xss("css", it -> CssEscape.escapeCssString(it, csstype, csslevel)) .xss("uri", UriEscape::escapeUriPath) .xss("queryParam", UriEscape::escapeUriQueryParam) .xss("uriFragmentId", UriEscape::escapeUriFragmentId); }
void addReference(final int codepoint, final String ncr) { this.references.add(new Reference(ncr, new int[]{codepoint})); }
@Override public void toJson(String choice, JSONWriter writer) throws JSONException { String escaped = HtmlEscape.escapeHtml5(choice); writer.key("id").value(choice).key("name").value(escaped); }
public int compare(final char[] o1, final char[] o2) { return HtmlEscapeSymbols.compare(o1, o2, 0, o2.length); } });
private static String getParagraph(String section) { Matcher matcher = PARAGRAPH.matcher(section); if(!matcher.find()) return null; return HtmlEscape.unescapeHtml(matcher.group(1)).replaceAll("(?s)[\\r\\n\\s]+", " "); }
@Override protected String produceEscapedOutput(final Object input) { if (input == null) { return ""; } return HtmlEscape.escapeHtml4Xml(input.toString()); }
void addReference(final int codepoint0, final int codepoint1, final String ncr) { this.references.add(new Reference(ncr, new int[] { codepoint0, codepoint1 })); }
private static Collection<Author> getAuthors(String section) { Matcher matcher = ITEM.matcher(section); LinkedList<Author> list = new LinkedList<Author>(); while(matcher.find()) { list.add(Author.fromString(HtmlEscape.unescapeHtml(matcher.group(1)))); } return list; }
/** * <p> * XML-escapes the specified text. * </p> * * @param target the text to be escaped * @return the escaped text. * @since 2.0.9 */ public static String escapeXml(final Object target) { if (target == null) { return null; } return HtmlEscape.escapeHtml4Xml(target.toString()); }
@Override public void onContentFetched(byte[] content) { String body = new String(content); Matcher matcher = RESULT.matcher(body); while(matcher.find()) { Exploit exploit = new Exploit(Integer.parseInt(matcher.group(2)), HtmlEscape.unescapeHtml(matcher.group(3))); exploit.setPort(port); try { job.add(new String(matcher.group(1).toCharArray()), new ExploitReceiver(job, exploit, receiver)); } catch (MalformedURLException e) { Logger.error(String.format("Bad URL: %s", matcher.group(1))); } catch (IllegalStateException e) { Logger.warning(e.getMessage()); } receiver.onItemFound(exploit); } synchronized (this) { if (!analyzePagination) return; analyzePagination = false; } parsePages(body); }
private static String produceEscapedOutput(final TemplateMode templateMode, final String input) { switch (templateMode) { case TEXT: // fall-through case HTML: return HtmlEscape.escapeHtml4Xml(input); case XML: // Note we are outputting a body content here, so it is important that we use the version // of XML escaping meant for content, not attributes (slight differences) return XmlEscape.escapeXml10(input); default: throw new TemplateProcessingException( "Unrecognized template mode " + templateMode + ". Cannot produce escaped output for " + "this template mode."); } }
return HtmlEscape.unescapeHtml(input); case XML: return XmlEscape.unescapeXml(input);
public static String escapeAttribute(final TemplateMode templateMode, final String input) { if (input == null) { return null; } Validate.notNull(templateMode, "Template mode cannot be null"); /* * Depending on the template mode that we are using, we might be receiving element attributes escaped in * different ways. * * HTML and XML have their own escaping/unescaping rules, which we can easily apply by means * of the corresponding Unbescape utility methods. TEXT, JAVASCRIPT and CSS are left out because there are no * attributes to be output in those modes as such. * * There is no standard way to escape/unescape in TEXT modes, but given TEXT mode is many times used for * markup (HTML or XML templates or inlined fragments), we will use HTML escaping/unescaping for TEXT mode. * Besides, this is consistent with the fact that TEXT-mode escaped output will also be HTML-escaped by * processors and inlining utilities in the Standard Dialects. */ switch (templateMode) { case HTML: return HtmlEscape.escapeHtml4Xml(input); case XML: return XmlEscape.escapeXml10Attribute(input); default: throw new TemplateProcessingException( "Unrecognized template mode " + templateMode + ". Cannot produce escaped attributes for " + "this template mode."); } }
/** * <p> * Returns the textual content of this node, as a String. * </p> * * @return the textual content of this node. */ public String getContent() { if (this.contentIsEscaped) { return HtmlEscape.unescapeHtml(this.content); } return this.content; }
HtmlEscape.escapeHtml4Xml(this.input.toString(), writer);
/** * <p> * Returns the value of the attribute. * </p> * * @return the value of the attribute. */ public String getValue() { if (this.valueIsEscaped) { return HtmlEscape.unescapeHtml(this.value); } return this.value; }
/** * <p> * Returns the escaped value of the attribute. * </p> * * @return the value of the attribute. * @since 2.1.3 */ public String getEscapedValue() { if (this.valueIsEscaped) { return this.value; } return HtmlEscape.escapeHtml4Xml(this.value); }
/** * <p> * Returns the textual and escaped content of this node, as a String. * </p> * * @return the textual content of this node. * @since 2.1.3 */ public String getEscapedContent() { if (this.contentIsEscaped) { return this.content; } return HtmlEscape.escapeHtml4Xml(this.content); }