Encodes a given input for use in a general HTML context.
Encodes a given input for use in an HTML Attribute guarded by a double quote.
Encodes a given input for use in an HTML Attribute guarded by a single quote.
Encodes a given input for use in an HTML Attribute left unguarded.
Encodes a given input for use in JavaScript inside an HTML attribute.
Encodes a given input for use in JavaScript inside an HTML block.
Encodes a given input for use in JavaScript inside an HTML context.
Encodes a given input for use in JavaScript inside a JavaScript source file.
Encodes a given input for use in a JSON Object Value to prevent escaping into a trusted context.
Encodes a given input for use as a component of a URI.
Encodes a given input for use as a component of a URI.
Encodes a given input for use in an XML comments.
Encodes a given input for use in a general XML context.
Encodes a given input for use in an XML attribute guarded by a double quote.
Encodes a given input for use in an XML attribute guarded by a single quote.
Encodes a given input for use in a general HTML context. E.g. text content and text attributes. This method takes the UNION of allowed characters between the two context, so may be more imprecise that the more specific contexts. Generally, this method is preferred unless you specifically understand the context in which untrusted data will be output.
Example Usage:<div>${SecureEncoder.forHtmlContent(unsafeData)}</div> <input value="${SecureEncoder.forHtmlContent(unsafeData)}" />Flow:
Encodes a given input for use in an HTML Attribute guarded by a double quote. This method is preferred if you understand exactly how the output of this will be used in the HTML document.
Example Usage:<div id="${SecureEncoder.forHtmlInDoubleQuoteAttribute(unsafeData)}"></div>Flow:
Encodes a given input for use in an HTML Attribute guarded by a single quote. This method is preferred if you understand exactly how the output of this will be used in the HTML document.
Example Usage:<div id='${SecureEncoder.forHtmlInSingleQuoteAttribute(unsafeData)}'></div>Flow:
Encodes a given input for use in an HTML Attribute left unguarded. This method is preferred if you understand exactly how the output of this will be used in the HTML document.
Example Usage:<div id=${SecureEncoder.forHtmlUnquotedAttribute(unsafeData)}></div>Flow:
Encodes a given input for use in JavaScript inside an HTML attribute. This method is preferred if you understand exactly how the output of the will be used in the page
Example Usage:<button onclick="alert('${SecureEncoder.forJavaScriptInAttribute(unsafeData)}');">Flow:
Encodes a given input for use in JavaScript inside an HTML block. This method is preferred if you understand exactly how the output of the will be used in the page
Example Usage:<script type="text/javascript"> var data = "${SecureEncoder.forJavaScriptInBlock(unsafeData)}"; </script>Flow:
Encodes a given input for use in JavaScript inside an HTML context. This method takes the UNION of allowed characters among the other contexts, so may be more imprecise that the more specific contexts. Generally, this method is preferred unless you specifically understand the context in which untrusted data will be output.
Example Usage:<script type="text/javascript"> var data = "${SecureEncoder.forJavaScriptInHTML(unsafeData)}"; </script> <button onclick="alert('${SecureEncoder.forJavaScriptInHTML(unsafeData)}');">Flow:
Encodes a given input for use in JavaScript inside a JavaScript source file. This method is preferred if you understand exactly how the output of the will be used in the page
Example Usage:<...inside foobar.js...> var data = "${SecureEncoder.forJavaScriptInSource(unsafeData)}";Flow:
Encodes a given input for use in a JSON Object Value to prevent escaping into a trusted context.
Example Usage:var json = {"trusted_data" : SecureEncoder.forJSONValue(unsafeData)}; return JSON.stringify(json);Flow:
Encodes a given input for use as a component of a URI. This is equivalent to javascript's encodeURIComponent and does a realistic job of encoding.
Example Usage:<a href="http://host.com?value=${SecureEncoder.forUriComponent(unsafeData)}"/>Allows:
A-Z, a-z, 0-9, -, _, ., ~, !, *, ', (, )Flow:
Encodes a given input for use as a component of a URI. This is a strict encoder and fully complies with RFC3986.
Example Usage:<a href="http://host.com?value=${SecureEncoder.forUriComponentStrict(unsafeData)}"/>Allows:
A-Z, a-z, 0-9, -, _, ., ~Flow:
Encodes a given input for use in an XML comments. This method is preferred if you understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method can be misused, but is left here if a parser is unavailable to you<!-- ${SecureEncoder.forXmlCommentContent(unsafeData)} -->Flow:
Encodes a given input for use in a general XML context. E.g. text content and text attributes. This method takes the UNION of allowed characters between the other contexts, so may be more imprecise that the more specific contexts. Generally, this method is preferred unless you specifically understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method can be misused, but is left here if a parser is unavailable to you<foo>${SecureEncoder.forXmlContent(unsafeData)}</foo> <bar attr="${SecureEncoder.forXmlContent(unsafeData)}"></bar>Flow:
Encodes a given input for use in an XML attribute guarded by a double quote. This method is preferred if you understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method can be misused, but is left here if a parser is unavailable to you<bar attr="${SecureEncoder.forXmlInDoubleQuoteAttribute(unsafeData)}"></bar>Flow:
Encodes a given input for use in an XML attribute guarded by a single quote. This method is preferred if you understand the context in which untrusted data will be output.
Note: It is recommended that you use a real parser, as this method can be misused, but is left here if a parser is unavailable to you<bar attr='${SecureEncoder.forXmlInSingleQuoteAttribute(unsafeData)}'></bar>Flow: