Package fr.paris.lutece.util.string
Class StringUtil
java.lang.Object
fr.paris.lutece.util.string.StringUtil
This class provides String utils.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckCodeKey(String strCodeKey) Check a code key.
Return true if each character of String is number lower case upper casestatic booleancheckEmail(String strEmail) This function checks if an email is in a valid format Returns true if the email is validstatic booleancheckEmailAndDomainName(String strEmail, String[] strBannedDomainNames) This function checks if an email is in a valid format, and is not in a banned domain names list.static booleancheckEmailDomainName(String strEmail, String[] strBannedDomainNames) Check if a domain name of an email address is not in a banned domain names list.static byte[]compress (with default UTF-8 encoding)static booleancontainsHtmlSpecialCharacters(String strValue) Checks if a string literal contains any HTML special characters (&, ", ' <, >).static booleancontainsXssCharacters(String strValue) Checks if a String contains characters that could be used for a cross-site scripting attack.static booleancontainsXssCharacters(String strValue, char[] aXssCharacters) Checks if a String contains characters that could be used for a cross-site scripting attack.static booleancontainsXssCharacters(String strValue, String strXssCharacters) Checks if a String contains characters that could be used for a cross-site scripting attack.static StringdecodeXssBypass(String strBase64Value) Decodes a Base64-encoded string that was encoded client-side by the bypassXssFilter mechanism of the input macro.static Stringdecompress(byte[] bytes) uncompress (with default UTF-8 encoding)static Stringdecompress(byte[] bytes, String encoding) uncompressstatic intgetIntValue(String strValue, int nDefaultValue) ConvertsstrValueto an int value.static StringSimple convenience method to return the XSS characters as a string, to include it in error messages.static booleanisAnyEmpty(String... strings) Return true if any of the strings is empty, false otherwisestatic StringreplaceAccent(String strSource) This function converts French diacritics characters into non diacritics.static Stringsubstitute(String strSource, String strValue, String strBookmark) This function substitutes all occurences of a given bookmark by a given value
-
Method Details
-
substitute
This function substitutes all occurences of a given bookmark by a given value- Parameters:
strSource- The input string that contains bookmarks to replacestrValue- The value to substitute to the bookmarkstrBookmark- The bookmark name- Returns:
- The output string.
-
replaceAccent
This function converts French diacritics characters into non diacritics.- Parameters:
strSource- The String to convert- Returns:
- The sTring converted to French non diacritics characters
-
containsHtmlSpecialCharacters
Checks if a string literal contains any HTML special characters (&, ", ' <, >).- Parameters:
strValue- The string literal to check- Returns:
- True if the string literal contains any special character
-
containsXssCharacters
Checks if a String contains characters that could be used for a cross-site scripting attack.- Parameters:
strValue- a character String- Returns:
- true if the String contains illegal characters
-
containsXssCharacters
Checks if a String contains characters that could be used for a cross-site scripting attack.- Parameters:
strValue- a character StringaXssCharacters- a Xss characters tab to check in strValue- Returns:
- true if the String contains illegal characters
-
containsXssCharacters
Checks if a String contains characters that could be used for a cross-site scripting attack.- Parameters:
strValue- a character StringstrXssCharacters- a String wich contain a list of Xss characters to check in strValue- Returns:
- true if the String contains illegal characters
-
getXssCharactersAsString
Simple convenience method to return the XSS characters as a string, to include it in error messages.- Returns:
- a String containing a comma-separated list of the XSS characters
-
checkEmail
This function checks if an email is in a valid format Returns true if the email is valid- Parameters:
strEmail- The mail to check- Returns:
- boolean true if strEmail is valid
-
checkEmailAndDomainName
This function checks if an email is in a valid format, and is not in a banned domain names list. Returns true if the email is valid- Parameters:
strEmail- The mail to checkstrBannedDomainNames- The list of banned domain names. Domain names may start with a '@' or not.- Returns:
- boolean true if strEmail is valid, false otherwise
-
checkEmailDomainName
Check if a domain name of an email address is not in a banned domain names list.- Parameters:
strEmail- Email addresse to checkstrBannedDomainNames- List of banned domain names- Returns:
- True if the email address is correct, false otherwise
-
checkCodeKey
Check a code key.
Return true if each character of String is- number
- lower case
- upper case
- Parameters:
strCodeKey- The code Key- Returns:
- True if code key is valid
-
getIntValue
ConvertsstrValueto an int value.- Parameters:
strValue- the value to convertnDefaultValue- the default returned value- Returns:
strValueint value,nDefaultValueif strValue is not an Integer.
-
isAnyEmpty
Return true if any of the strings is empty, false otherwise- Parameters:
strings- the strings to test- Returns:
-
compress
compress (with default UTF-8 encoding)- Parameters:
the- string to compress- Returns:
- the compressed string
- Throws:
IOException
-
decompress
uncompress (with default UTF-8 encoding)- Parameters:
the- compressed string- Returns:
- the uncompressed string
- Throws:
IOException
-
decompress
uncompress- Parameters:
the- compressed stringthe- encoding- Returns:
- the uncompressed string
- Throws:
IOException
-
decodeXssBypass
Decodes a Base64-encoded string that was encoded client-side by the bypassXssFilter mechanism of the input macro. This allows form fields to bypass the global XSS sanitizer filter without disabling it entirely.- Parameters:
strBase64Value- the Base64-encoded string received from the form field- Returns:
- the decoded original string, or null if the input is null
- Throws:
IllegalArgumentException- if the input is not valid Base64
-