-
Notifications
You must be signed in to change notification settings - Fork 45
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
Improper handling of boolean attributes? #186
Comments
Fixing this would require patching html5ever::serialize to special-case boolean attributes. The implementation code is here. Is this a blocking issue? I'd rather not take on patched copies of html5ever code if it's just there to trim a few bytes off a seldom-used feature. |
Thanks - it's not blocking just yet. Should this be re-opened against the underlying library instead? |
That might be the best place to do it, though since the html5 serialization algorithm that it implements doesn't call for this, they probably don't want to merge it.
|
Hmm, I guess so 🤔 Since trailing empty Thanks for your assistance! |
Thanks for the pointers, I ended up adding the trailing |
Hello! Thanks for the nifty library.
Apologies if this is reported elsewhere, or if I'm using the incorrect language. I've not done much Rust, and came to this library from the Python wrapper nh3, but I think I have an example in Rust that shows the issue.
When passing a value to
tag_attributes
to allow it through the cleansing cycle, it looks like the code doesn't currently know how to use boolean-type attributes.One such instance I'm hitting is
disabled
tag attribute.Then used in HTML, this often looks like:
However when passing this to ammonia, the output becomes:
Note the trailing
=""
While valid HTML, and executes correctly in the browser I tested, it becomes a more verbose syntax, and unnecessarily adds characters to the output HTML.
Here's an example demonstrating the issue:
I found this listing of boolean attributes, updated July 2023 - it might be useful.
Alternately, if the source tag attribute has no
=
value, maybe don't add it?The text was updated successfully, but these errors were encountered: