Skip to content

Commit b98f2c5

Browse files
authored
Expose default clean_content_tags as module constant (#118)
Co-authored-by: gghez <gghez@users.noreply.github.com>
1 parent 9fdfa76 commit b98f2c5

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

nh3.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ from typing import Callable, Dict, Optional, Set
33
ALLOWED_TAGS: Set[str]
44
ALLOWED_ATTRIBUTES: Dict[str, Set[str]]
55
ALLOWED_URL_SCHEMES: Set[str]
6+
CLEAN_CONTENT_TAGS: Set[str]
67

78
class Cleaner:
89
def __init__(

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,5 +484,6 @@ fn nh3(_py: Python, m: &Bound<PyModule>) -> PyResult<()> {
484484
m.add("ALLOWED_TAGS", a.clone_tags())?;
485485
m.add("ALLOWED_ATTRIBUTES", a.clone_tag_attributes())?;
486486
m.add("ALLOWED_URL_SCHEMES", a.clone_url_schemes())?;
487+
m.add("CLEAN_CONTENT_TAGS", a.clone_clean_content_tags())?;
487488
Ok(())
488489
}

tests/test_nh3.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ def test_clean_text():
135135
assert res == "Robert&quot;);&#32;abuse();&#47;&#47;"
136136

137137

138+
def test_clean_content_tags_constant():
139+
assert isinstance(nh3.CLEAN_CONTENT_TAGS, set)
140+
assert "script" in nh3.CLEAN_CONTENT_TAGS
141+
assert "style" in nh3.CLEAN_CONTENT_TAGS
142+
143+
138144
def test_is_html():
139145
assert not nh3.is_html("plain text")
140146
assert nh3.is_html("<p>html!</p>")

0 commit comments

Comments
 (0)