public class StringUtils extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static org.owasp.html.PolicyFactory |
basePolicy |
protected static org.owasp.html.PolicyFactory |
docPolicy |
protected static boolean |
overrideDocType
default value - NOTE: see spring-webscripts-application-context.xml
|
| Constructor and Description |
|---|
StringUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
cropEncode(String text)
Crop a label within a SPAN element, using ellipses '...' at the end of label and
and encode the result for HTML output.
|
static String |
cropEncode(String text,
int length)
Crop a label within a SPAN element, using ellipses '...' at the end of label and
and encode the result for HTML output.
|
static String |
encode(String string)
Encodes the given string, so that it can be used within an HTML page.
|
static String |
encodeJavascript(String s)
Encode a string to the %AB hex style JavaScript compatible notation.
|
static String |
join(Object[] value)
Join an array of values into a String value
|
static String |
join(Object[] value,
String delim)
Join an array of values into a String value using supplied delimiter between each.
|
static String |
remove(String str,
String match)
Remove all occurances of a String from a String
|
static String |
replace(String str,
String repl,
String with)
Replace one string instance with another within the specified string
|
static String |
replaceLineBreaks(String str,
boolean xhtml)
Replaces carriage returns and line breaks with the <br> tag.
|
void |
setOverrideDocType(boolean overrideDocType) |
static String |
stripUnsafeHTMLDocument(String doc,
boolean encode)
Strip unsafe HTML tags from a string that represent an entire hml doc - only leaves most basic formatting tags
and optionally encodes or strips the remaining characters.
|
static String |
stripUnsafeHTMLTags(String s)
Strip unsafe HTML tags from a string - only leaves most basic formatting tags
and encodes the remaining characters.
|
static String |
stripUnsafeHTMLTags(String s,
boolean encode)
Strip unsafe HTML tags from a string - only leaves most basic formatting tags
and optionally encodes or strips the remaining characters.
|
static String |
stripUnsafeHTMLTags(String s,
boolean encode,
boolean overrideDocumentType)
Strip unsafe HTML tags from a string - only leaves most basic formatting tags
and optionally encodes or strips the remaining characters.
|
static String |
stripUnsafeHTMLTags(String s,
boolean encode,
boolean overrideDocumentType,
boolean isHTMLDoc)
Strip unsafe HTML tags from a string - only leaves most basic formatting tags
|
static String |
stripUnsafeHTMLTags(String s,
boolean encode,
boolean overrideDocumentType,
boolean isHTMLDoc,
boolean runTwice)
Strip unsafe HTML tags from a string - only leaves most basic formatting tags
|
protected static boolean overrideDocType
protected static org.owasp.html.PolicyFactory basePolicy
protected static org.owasp.html.PolicyFactory docPolicy
public void setOverrideDocType(boolean overrideDocType)
overrideDocType - Decides if legacy html !DOCTYPE instructions shall be transformed to the default modepublic static String encode(String string)
string - the String to convertpublic static String cropEncode(String text)
text - to crop and encodepublic static String cropEncode(String text, int length)
text - to crop and encodelength - length of string to crop toopublic static String encodeJavascript(String s)
s - string to encodepublic static String stripUnsafeHTMLTags(String s)
s - HTML string to strip tags frompublic static String stripUnsafeHTMLTags(String s, boolean encode)
s - HTML string to strip tags fromencode - if true then encode remaining html datapublic static String stripUnsafeHTMLDocument(String doc, boolean encode)
doc - HTML string representing an entire hml doc to strip tags fromencode - if true then encode remaining html datapublic static String stripUnsafeHTMLTags(String s, boolean encode, boolean overrideDocumentType)
s - HTML string to strip tags fromencode - if true then encode remaining html dataoverrideDocumentType - if true a doctype enforcing the latest browser rendition mode will usedpublic static String stripUnsafeHTMLTags(String s, boolean encode, boolean overrideDocumentType, boolean isHTMLDoc)
s - HTML string to strip tags fromencode - if true then encode remaining html data (not in use)overrideDocumentType - if true a doctype enforcing the latest browser rendition mode will usedisHTMLDoc - if true elements as html, head, body will be allowed in the sanitizationpublic static String stripUnsafeHTMLTags(String s, boolean encode, boolean overrideDocumentType, boolean isHTMLDoc, boolean runTwice)
s - HTML string to strip tags fromencode - if true then encode remaining html data (not in use)overrideDocumentType - if true a doctype enforcing the latest browser rendition mode will usedisHTMLDoc - if true elements as html, head, body will be allowed in the sanitizationrunTwice - if true, performs a second iteration against the first sanitation resultpublic static String replace(String str, String repl, String with)
str - Stringrepl - Stringwith - Stringpublic static String remove(String str, String match)
str - String to remove occurances frommatch - The string to removepublic static String replaceLineBreaks(String str, boolean xhtml)
str - The string to be parsedpublic static String join(Object[] value)
value - non-null array of objects - toString() of each value is usedpublic static String join(Object[] value, String delim)
value - non-null array of objects - toString() of each value is useddelim - delimiter value to apply between each value - null indicates no delimiterCopyright © 2005–2021 Alfresco Software. All rights reserved.