Closed kyle-simmons closed 5 years ago
@mikesamuel Could you review this PR and provide feedback on if this is behavior we want to allow? I think regardless a StringIndexOutOfBoundsException
is not ideal.
Sorry for the delay. Thanks for the testcase. I think there's a more minimal fix at L1008.
Folded your test and a tweaked fix at https://github.com/OWASP/java-html-sanitizer/commit/83c4ce38014d42709c8262804bba8254dfa2a30c
When using the
HtmlPolicyBuilder
, if bothnoopener
andnoreferrer
are supplied toskipRelsOnLinks
, then aStringIndexOutOfBoundsException
will get thrown when applying sanitization on elements that have both anhref
andtarget
. This PR addresses that issue by only attempting to apply rels to the element if we actually have a non-zero set of rels to apply.Addresses https://github.com/OWASP/java-html-sanitizer/issues/151