org.owasp.esapi.tags
Class ELEncodeFunctions

java.lang.Object
  extended by org.owasp.esapi.tags.ELEncodeFunctions

public class ELEncodeFunctions
extends java.lang.Object

Static encoder methods for JSP EL expression functions.


Method Summary
static java.lang.String encodeForBase64(java.lang.String str)
          Base64 encode a string.
static java.lang.String encodeForBase64Charset(java.lang.String charset, java.lang.String str)
          Base64 encode a string after converting to bytes using the specified character set.
static java.lang.String encodeForBase64CharsetWrap(java.lang.String charset, java.lang.String str)
          Base64 encode a string after converting to bytes using the specified character set and wrapping lines.
static java.lang.String encodeForBase64Wrap(java.lang.String str)
          Base64 encode a string with line wrapping.
static java.lang.String encodeForCSS(java.lang.String str)
          Encode string for use in CSS.
static java.lang.String encodeForHTML(java.lang.String str)
          Encode string for use in HTML.
static java.lang.String encodeForHTMLAttribute(java.lang.String str)
          Encode string for use in a HTML attribute.
static java.lang.String encodeForJavaScript(java.lang.String str)
          Encode string for use in JavaScript.
static java.lang.String encodeForURL(java.lang.String str)
          Encode string for use in a URL.
static java.lang.String encodeForVBScript(java.lang.String str)
          Encode string for use in VBScript.
static java.lang.String encodeForXML(java.lang.String str)
          Encode string for use in XML.
static java.lang.String encodeForXMLAttribute(java.lang.String str)
          Encode string for use in a XML attribute.
static java.lang.String encodeForXPath(java.lang.String str)
          Encode string for use in XPath.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

encodeForBase64

public static java.lang.String encodeForBase64(java.lang.String str)
                                        throws java.io.UnsupportedEncodingException
Base64 encode a string. UTF-8 is used to encode the string and no line wrapping is performed.

Parameters:
str - The string to encode.
Returns:
The base64 encoded String.
Throws:
java.io.UnsupportedEncodingException - if UTF-8 is an unsupported character set. This should not happen as UTF-8 is required to be supported by the JVM spec.
See Also:
Encoder.encodeForBase64(byte[],boolean)

encodeForBase64Wrap

public static java.lang.String encodeForBase64Wrap(java.lang.String str)
                                            throws java.io.UnsupportedEncodingException
Base64 encode a string with line wrapping. UTF-8 is used to encode the string and lines are wrapped at 64 characters..

Parameters:
str - The string to encode.
Returns:
The base64 encoded String.
Throws:
java.io.UnsupportedEncodingException - if UTF-8 is an unsupported character set. This should not happen as UTF-8 is required to be supported by the JVM spec.
See Also:
Encoder.encodeForBase64(byte[],boolean)

encodeForBase64Charset

public static java.lang.String encodeForBase64Charset(java.lang.String charset,
                                                      java.lang.String str)
                                               throws java.io.UnsupportedEncodingException
Base64 encode a string after converting to bytes using the specified character set. No line wrapping is performed.

Parameters:
charset - The character set used to convert str to bytes.
str - The string to encode.
Returns:
The base64 encoded String.
Throws:
java.io.UnsupportedEncodingException - if charset is an unsupported character set.
See Also:
Encoder.encodeForBase64(byte[],boolean)

encodeForBase64CharsetWrap

public static java.lang.String encodeForBase64CharsetWrap(java.lang.String charset,
                                                          java.lang.String str)
                                                   throws java.io.UnsupportedEncodingException
Base64 encode a string after converting to bytes using the specified character set and wrapping lines. Lines are wrapped at 64 characters.

Parameters:
charset - The character set used to convert str to bytes.
str - The string to encode.
Returns:
The base64 encoded String.
Throws:
java.io.UnsupportedEncodingException - if charset is an unsupported character set.
See Also:
Encoder.encodeForBase64(byte[],boolean)

encodeForCSS

public static java.lang.String encodeForCSS(java.lang.String str)
Encode string for use in CSS.

Parameters:
str - The string to encode.
Returns:
str encoded for use in CSS.
See Also:
Encoder.encodeForCSS(String)

encodeForHTML

public static java.lang.String encodeForHTML(java.lang.String str)
Encode string for use in HTML.

Parameters:
str - The string to encode.
Returns:
str encoded for use in HTML.
See Also:
Encoder.encodeForHTML(String)

encodeForHTMLAttribute

public static java.lang.String encodeForHTMLAttribute(java.lang.String str)
Encode string for use in a HTML attribute.

Parameters:
str - The string to encode.
Returns:
str encoded for use in HTML attribute.
See Also:
Encoder.encodeForHTMLAttribute(String)

encodeForJavaScript

public static java.lang.String encodeForJavaScript(java.lang.String str)
Encode string for use in JavaScript.

Parameters:
str - The string to encode.
Returns:
str encoded for use in JavaScript.
See Also:
Encoder.encodeForJavaScript(String)

encodeForURL

public static java.lang.String encodeForURL(java.lang.String str)
                                     throws EncodingException
Encode string for use in a URL.

Parameters:
str - The string to encode.
Returns:
str encoded for use in a URL.
Throws:
EncodingException
See Also:
Encoder.encodeForURL(String)

encodeForVBScript

public static java.lang.String encodeForVBScript(java.lang.String str)
Encode string for use in VBScript.

Parameters:
str - The string to encode.
Returns:
str encoded for use in VBScript.
See Also:
Encoder.encodeForVBScript(String)

encodeForXML

public static java.lang.String encodeForXML(java.lang.String str)
Encode string for use in XML.

Parameters:
str - The string to encode.
Returns:
str encoded for use in XML.
See Also:
Encoder.encodeForXML(String)

encodeForXMLAttribute

public static java.lang.String encodeForXMLAttribute(java.lang.String str)
Encode string for use in a XML attribute.

Parameters:
str - The string to encode.
Returns:
str encoded for use in XML attribute.
See Also:
Encoder.encodeForXMLAttribute(String)

encodeForXPath

public static java.lang.String encodeForXPath(java.lang.String str)
Encode string for use in XPath.

Parameters:
str - The string to encode.
Returns:
str encoded for use in XPath.
See Also:
Encoder.encodeForXPath(String)


Copyright © 2011 The Open Web Application Security Project (OWASP). All Rights Reserved.