public final class StringEscapeHelper extends Object
Modifier and Type | Method and Description |
---|---|
static String |
escapeJavaScript(String str)
Escapes backslash, single and double quotes with a backslash.
|
static String |
escapeJavaScriptInlineHtml(String str)
Escapes strings which should be used as string literals in JavaScript code that is rendered
in HTML inline event handler attributes like onclick or inside a script tag.
|
static String |
escapeJsonInlineHtml(String str)
Escapes serialized JSON which should be used in JavaScript code that is rendered inside a
script tag.
|
static String |
escapeNonWordCharacters(String str)
Escape characters that are not in the slightly extended word regex character class with an
underscore.
|
static String |
escapeXml(String buffer)
Performs the following substring replacements (to facilitate output to XML/HTML pages):
& with & < with < > with > " with " ' with ' |
static String |
getSingleLineTextFromXML(String html)
get the text of the xml content and replace linebreaks with a whitespace
|
static String |
removeHtmlMarkup(String str)
Removes all tags from a string and replaces HTML 4.0 entities with the corresponding Unicode
character.
|
static String |
removeXmlMarkup(String str)
Removes XML markup from a string and unescapes XML entities (only gt, lt, quot, amp, apos).
|
public static String escapeJavaScript(String str)
str
- the string to escapepublic static String escapeJavaScriptInlineHtml(String str)
str
- the string to escapepublic static String escapeJsonInlineHtml(String str)
str
- the serialized JSON to escapepublic static String escapeNonWordCharacters(String str)
str
- the string to escapepublic static String escapeXml(String buffer)
buffer
- the string to escape XML entitiespublic static String getSingleLineTextFromXML(String html)
html
- the html text to analpublic static String removeHtmlMarkup(String str)
str
- the string to modifyCopyright © 2019 Communote team. All rights reserved.