clean shouldn't remove target attributes by default #79

phzbox opened this Issue Nov 21, 2012 · 2 comments


None yet

2 participants

# Adding target="_blank"
bleach.clean(bleach.linkify(foo, callbacks=[add_target]))

Doesn't work because .clean remove "target" attributes by default.

Mozilla member

This behavior is correct. You're calling clean after calling linkify, so you need to tell clean which tags and attributes (including the ones you've added in linkify) to allow. You should reverse the order, or be explicit and allow <a> tags with target attributes in clean.

@jsocol jsocol closed this Nov 26, 2012

That is the fix I have used. However, I supposed that by default, common attributes would be allowed. For instance, if I call .clean on <a href="#">test</a>, I would assume that the "href" attribute is kept. I won't reopen as I agree this is not a bug, maybe just something confusing for new users of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment