OWASP / java-html-sanitizer

Takes third-party HTML and produces HTML that is safe to embed in your web application. Fast and easy to configure.
Other
850 stars 214 forks source link

How to customize the policy after defining the policy. #279

Open zubairkhan1133 opened 1 year ago

zubairkhan1133 commented 1 year ago

Hello, I am using this library, I am stuck at one point. I want to know after defining the policy, how can I again customize it. Like I want to add more attributes and elements after defining it. for e.g. the defined policy is PolicyFactory POLICY_DEFINITION = new HtmlPolicyBuilder() .allowAttributes(allowAttributesGlobally).globally() .allowAttributes("src").onElements("img", "script", "iframe") .allowAttributes("href").onElements("a") .allowElements("a", "img", "script", "iframe") .toFactory();

now I want to add 'link' attribute of 'body' tag and 'onload' attribute of 'a' tag. How can I add these after defining the policy