/** * Sanitizes a URI. * * <p> * This method returns the URI provided if it is safe to use as the value * of a URI-valued HTML attribute according to {@link #isSafeUri}, or the URI * "{@code #}" otherwise. * * @param uri the URI to sanitize * @return a sanitized String */ @IsSafeUri @SuppressIsSafeUriCastCheck public static String sanitizeUri(String uri) { if (isSafeUri(uri)) { return encodeAllowEscapes(uri); } else { return "#"; } }
/** * Sanitizes a URI. * * <p> * This method returns the URI provided if it is safe to use as the value * of a URI-valued HTML attribute according to {@link #isSafeUri}, or the URI * "{@code #}" otherwise. * * @param uri the URI to sanitize * @return a sanitized String */ public static String sanitizeUri(String uri) { if (isSafeUri(uri)) { return encodeAllowEscapes(uri); } else { return "#"; } }
/** * Sanitizes a URI. * * <p> * This method returns the URI provided if it is safe to use as the value * of a URI-valued HTML attribute according to {@link #isSafeUri}, or the URI * "{@code #}" otherwise. * * @param uri the URI to sanitize * @return a sanitized String */ public static String sanitizeUri(String uri) { if (isSafeUri(uri)) { return encodeAllowEscapes(uri); } else { return "#"; } }