Search code examples
htmljsonjsoupwhitelist

Jsoup whitelist sanitizer for data-* attributes


Utilizing the jsoup whitelist sanitizer to clean html prior to being serialized (json) and ajaxed.

How to allow for all data-* attributes in html without having to explicitly add each instance to the whitelist?


Solution

  • I don't think there is a built in function for that. What you could do though is, take your html string, search for every data attribute (a regex would be a good idea) and add them in a loop explicitly.