public static String asValidHref ( String urlString ) { try { return new URL ( urlString ) . toExternalForm ( ) ; } catch ( MalformedURLException e ) { LOG . debug ( "Malformed url - {}, empty string will be returned" , urlString ) ; return "" ; } }
Method to filter invalid url for XSS . This url can be inserted to href safely