I looked at the reference you posted and did not see anything about the requirement for an array.
Hi Dan. The addTags() method doesn't say it needs to be an array either, but it will only work if it's supplied by CF as an array. I got that tip from a Stackoverflow answer I found. Unfortunately it doesn't work for the addAttributess() method. I've tried supplying a string as well, trying to cover all posibilities.
Anyone use jsoup or know about sending an array to a Java object? Thanks.
You can see the setAttributes() method signature like so:
<cfset whitelist = CreateObject("java", "org.jsoup.safety.Whitelist")>
<cfdump var="#Whitelist.relaxed()#" />
If you run that you will see setAttributes() expects a string and a string array.
Given that, you need to do something like:
jsoup = CreateObject("java","org.jsoup.Jsoup");
whitelist = CreateObject("java", "org.jsoup.safety.Whitelist");
html="<div style='font-size:24pt;'>This is BIG text</div>. This is an unwanted script: <script>alert('Boo!')</script>.<br>";
sanitized = jsoup.clean(html, Whitelist.relaxed().addAttributes(":all" , JavaCast("string", myKeys)));
Nathan, thank you so much for your reply. That was a perfect answer and my code is working now.
I didn't realise the method needed a string and an array, I was shoving both into a single array. Doh to me and yay to you! I wish there was a "jump for joy" emoticon in the forum.