@ Nullable public static String getWithoutForbiddenChars ( @ Nullable final String s ) { if ( s == null ) return null ; final StringBuilder aCleanValue = new StringBuilder ( s . length ( ) ) ; int nForbidden = 0 ; for ( final char c : s . toCharArray ( ) ) if ( isForbiddenParamValueChar ( c ) ) nForbidden ++ ; else aCleanValue . append ( c ) ; if ( nForbidden == 0 ) { // Return "as-is" return s ; } if ( LOGGER . isWarnEnabled ( ) ) LOGGER . warn ( "Removed " + nForbidden + " forbidden character(s) from a request parameter value!" ) ; return aCleanValue . toString ( ) ; }
Remove all chars from the input that cannot be serialized as XML .