Skip to content
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

PanicException if allowed attribute is missing #36

Open
Alex3917 opened this issue Jan 22, 2024 · 2 comments
Open

PanicException if allowed attribute is missing #36

Alex3917 opened this issue Jan 22, 2024 · 2 comments

Comments

@Alex3917
Copy link

Alex3917 commented Jan 22, 2024

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()
@triopter
Copy link

I'm also encountering this error, which makes it pretty difficult to use the module.

@Ozzletroll
Copy link

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.

HelgeKrueger added a commit to HelgeKrueger/nh3 that referenced this issue Dec 22, 2024
messense pushed a commit that referenced this issue Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants