@Override protected String produceEscapedOutput(final Object input) { if (input == null) { return ""; } return HtmlEscape.escapeHtml4Xml(input.toString()); }
@Override protected String produceEscapedOutput(final Object input) { if (input == null) { return ""; } return HtmlEscape.escapeHtml4Xml(input.toString()); }
/** * <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()); }
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."); } }
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."); } }
HtmlEscape.escapeHtml4Xml(this.input.toString(), writer);
/** * <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); }
/** * <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> * 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()); }
/** * @deprecated Deprecated in 2.1.3. Will be removed in 3.0. Text and CDATA nodes do not perform XML-escaping anymore. */ @Deprecated AbstractTextNode(final String content, final boolean escapeXml, final String documentName, final Integer lineNumber) { super(documentName, lineNumber); Validate.notNull(content, "Content cannot be null"); if (escapeXml) { this.content = HtmlEscape.escapeHtml4Xml(content); this.contentIsEscaped = true; } else { this.content = content; this.contentIsEscaped = false; } }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null ? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null ? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null ? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null ? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null? "" : newAttributeValue)); }
@Override protected final void doProcess( final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue, final Object expressionResult, final IElementTagStructureHandler structureHandler) { String newAttributeValue = HtmlEscape.escapeHtml4Xml(expressionResult == null ? "" : expressionResult.toString()); // Let RequestDataValueProcessor modify the attribute value if needed newAttributeValue = RequestDataValueProcessorUtils.processUrl(context, newAttributeValue); // Set the real, non prefixed attribute StandardProcessorUtils.replaceAttribute(structureHandler, attributeName, this.targetAttributeDefinition, ATTR_NAME, (newAttributeValue == null ? "" : newAttributeValue)); }