nh3
nh3 copied to clipboard
PanicException if allowed attribute is missing
html = "<a href='http://www.google.com'>google.com</a>"
nh3.clean(html, tags={'a'}, attributes={'a': {'href', 'rel'}})
pyo3_runtime.PanicException: assertion failed: self.tag_attributes.get("a").and_then(|a| a.get("rel")).is_none()
I'm also encountering this error, which makes it pretty difficult to use the module.
I encountered this exact issue when replacing Bleach with nh3, and I had to remove "rel" from the attributes dict to avoid the error. Taking a look at the docs, I found:
link_rel (str) –
Configures a rel attribute that will be added on links, defaults to noopener noreferrer. To turn on rel-insertion, pass a space-separated list. If rel is in the generic or tag attributes, this must be set to None.
Hope this helps.