-
-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
Either I am misunderstanding what clean_content_tags does or it is not working correctly. I cannot get the clean_content_tags attribute to work on anything other than the two tags <script> and <style>. Using nh3 version 0.2.14, python 3.11.0.
import nh3
testItem = "<script>alert('hello')</script><p>hello</p>"
print(nh3.clean(html=testItem, clean_content_tags={'p'}))
I receive this error:
thread '<unnamed>' panicked at 'assertion failed: !self.tags.contains(tag_name)', /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ammonia-3.3.0/src/lib.rs:1792:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/Users/home/Desktop/import nh3.py", line 4, in <module>
print(nh3.clean(html=item, tags=None, clean_content_tags={'p'}))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: assertion failed: !self.tags.contains(tag_name)
I have been able to reproduce this error with b, br, div, and img tags. I haven't tried any others. script and style tags work as expected.
Metadata
Metadata
Assignees
Labels
No labels