public static String sanitize(final String input, final Policy policy) {
		if (policy == null) {
			throw new SystemException("AntiSamy policy cannot be null");
		}
		if (Util.empty(input)) {
			return input;
		}
		try {
			CleanResults results = ANTISAMY.scan(input, policy);
			String result = results.getCleanHTML();
			// Escape brackets for handlebars
			result = WebUtilities.encodeBrackets(result);
			return result;
		} catch (ScanException | PolicyException ex) {
			throw new SystemException("Cannot sanitize " + ex.getMessage(), ex);
		}
	}
public static String sanitize ( final String input , final Policy policy ) { if ( policy == null ) { throw new SystemException ( "AntiSamy policy cannot be null" ) ; } if ( Util . empty ( input ) ) { return input ; } try { CleanResults results = ANTISAMY . scan ( input , policy ) ; String result = results . getCleanHTML ( ) ; result = WebUtilities . encodeBrackets ( result ) ; return result ; } catch ( ScanException | PolicyException ex ) { throw new SystemException ( "Cannot sanitize " + ex . getMessage ( ) , ex ) ; } }
Apply sanitization rules to a HTML string.

@param input the (potentially) tainted HTML to sanitize
@param policy the AntiSamy policy to apply
@return sanitized HTML