'How to create custom safe list in jsoup to allow RFC 822 / RFC 2047 encoded address

Consider the string Amogh <[email protected]> is safe, now if I perform Jsoup clean operation like below:

System.out.println(Jsoup.clean("Amogh <[email protected]>", Safelist.none()));

It will only return Amogh (considering email address as unsafe) how can we make it to return Amogh <[email protected]> after cleaning any other HTML code.

Safe case:

System.out.println(Jsoup.clean("Amogh <[email protected]>", Safelist.none())); // Should print Amogh <[email protected]>

Unsafe case:

System.out.println(Jsoup.clean("Amogh <[email protected]><script>alert()</script>", Safelist.none())); // Should print Amogh <[email protected]>



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source