-
Notifications
You must be signed in to change notification settings - Fork 7
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
Passing tags and attributes to nh3.clean() #9
Comments
Thank you :) So, I'm not 100% sure if this would be better achieved through settings, field arguments or some other way or if maybe it shouldn't be done at all. The argument for not making the nh3 invocation configurable is that nh3's job here isn't to clean up the HTML, it's only to protect against XSS when someone circumvents the ProseMirror widget. As long as editors do not do anything strange ProseMirror will always serialize a cleaned up version of the HTML fragment already, even if you use the raw HTML popup. (That's also the reason why I use nh3 instead of something more opinionated such as html-sanitizer.) |
So @adamchainz wrote a post on
I find that kind of compelling, and we do know the restricted set of tags and attributes that should be allowed (I think π€)
I think it's safe as is, but could maybe be more so (hardened) by restricting the allowed tags. No sure either. But just working it through with you. |
I guess a validator here might show if someone was trying to be naughty π |
Yes, by looking at e.g. prosemirror-schema-basic, for example the link mark: I think the nodes and marks definitions in prosemirror-schema-basic and prosemirror-schema-list have been unchanged (practically) since the beginning. I have had discussions in private about allowing
Deriving the list of allowed attributes and tags from the
I totally agree with that, and I think there's value in hardening! A little more opinions on the server side would certainly be useful. Just to spell it out for everyone else, the cleaning is already more opinionated than nh3 is since e.g. the empty pararaph |
Great. Makes sense. I will try and prototype something when I get a small window. |
Hi @matthiask βΒ thanks for the great package, as always π
I have a question about the nh3 sanitizer:
django-prose-editor/django_prose_editor/sanitized.py
Lines 4 to 7 in 1a18e77
Here weβre using
clean
but I wonder if we could pass thetags
andattributes
arguments as well?Deriving those from the
types
used to instantiate the prose editor would allow precisely limiting the allowed HTML, Iβm hoping.What do you think?
The text was updated successfully, but these errors were encountered: