javaowaspantisamy

Antisamy removing string after script tag


I have a scenario where i pass a string through AntiSamy tag. The string is .

String dirtyContent = "<script>test<script>testing";
CleanResults cr = as.scan(dirtyContent, policy);
System.out.println(cr.getCleanHTML());

So i am expecting AntiSamy to remove the tag and its content and print testing. But AntiSamy is removing the entire content and return empty string. Can anyone help? Thanks.


Solution

  • I did an error that i recognized later. The script tag was not properly closed. <script>test<script>testing should have been <script>test</script>testing So internally what antisamy was doing is making <script>test<script>testing as <script>test<script>testing</script> and then removing the whole string. Caught this finally. Thanks for the help.