Package org.apache.tomcat.util.security
Class Escape
- java.lang.Object
- 
- org.apache.tomcat.util.security.Escape
 
- 
 public class Escape extends java.lang.ObjectProvides utility methods to escape content for different contexts. It is critical that the escaping used is correct for the context in which the data is to be used.
- 
- 
Constructor SummaryConstructors Constructor Description Escape()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringhtmlElementContent(java.lang.String content)Escape content for use in HTML.static java.lang.StringhtmlElementContext(java.lang.Object obj)Convert the object to a string viaObject.toString()and HTML escape the resulting string for use in HTML content.static java.lang.Stringxml(java.lang.String content)Escape content for use in XML.static java.lang.Stringxml(java.lang.String ifNull, boolean escapeCRLF, java.lang.String content)Escape content for use in XML.static java.lang.Stringxml(java.lang.String ifNull, java.lang.String content)Escape content for use in XML.
 
- 
- 
- 
Method Detail- 
htmlElementContentpublic static java.lang.String htmlElementContent(java.lang.String content) Escape content for use in HTML. This escaping is suitable for the following uses:- Element content when the escaped data will be placed directly inside tags such as <p>, <td> etc.
- Attribute values when the attribute value is quoted with " or '.
 - Parameters:
- content- The content to escape
- Returns:
- The escaped content or nullif the content wasnull
 
 - 
htmlElementContextpublic static java.lang.String htmlElementContext(java.lang.Object obj) Convert the object to a string viaObject.toString()and HTML escape the resulting string for use in HTML content.- Parameters:
- obj- The object to convert to String and then escape
- Returns:
- The escaped content or "?"if obj isnull
 
 - 
xmlpublic static java.lang.String xml(java.lang.String content) Escape content for use in XML.- Parameters:
- content- The content to escape
- Returns:
- The escaped content or nullif the content wasnull
 
 - 
xmlpublic static java.lang.String xml(java.lang.String ifNull, java.lang.String content)Escape content for use in XML.- Parameters:
- ifNull- The value to return if content is- null
- content- The content to escape
- Returns:
- The escaped content or the value of ifNullif the content wasnull
 
 - 
xmlpublic static java.lang.String xml(java.lang.String ifNull, boolean escapeCRLF, java.lang.String content)Escape content for use in XML.- Parameters:
- ifNull- The value to return if content is- null
- escapeCRLF- Should CR and LF also be escaped?
- content- The content to escape
- Returns:
- The escaped content or the value of ifNull if the content was
          null
 
 
- 
 
-