New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A cleaning pipeline #58
Comments
Well OK after rereading #56 a bit, I think this is very very similar to what you mean with |
#56 is specifically about The current |
In html5lib >= 0.99999999, sanitizing happens as a filter after tokenizing and you can easily add additional filters. With the rewrite for Bleach 2.0, you can trivially use the After I finish the rewrite, I'll verify that's true and add an item to the docs about it. |
One thing that occured to me while working on the
BleachSanitizerMixin.sanitize_token
is that it's code is getting pretty long and kind of ugly, the more functionality one needs do add.One possible way to counter this problem might be to implement a "pipeline". I've seen this concept first in django-social-auth which I'm also using in a project. To be more specific this part of the README explains it pretty good. Personally I really love the concept. The code of the default social auth pipeline is here
So what I am proposing is something very much in the vain of social auth's pipeline:
Instead of having to tie into the (big) if condition, we iterate over an iterable with functions::
While iterating, each function get's called and returns either a cleaned token which gets passed on to the next function in the iterable or
None
for skip. Note that maybe it might be more expressive to use Exceptions (likeSkipToken
) here.This may also clean up a bit of the code I introduce with the
strip_script_content
fork (like doingself.previous_token = token
right before everyreturn
)So, basically this is me requesting for a comment on refactoring things a bit :D – Maybe the same kind of pipeline-logic could be used for #56
The text was updated successfully, but these errors were encountered: