from backend.app.utils.html_sanitize import ( extract_img_srcs, rewrite_img_srcs, sanitize_post_html, ) def test_none_and_blank_return_none(): assert sanitize_post_html(None) is None assert sanitize_post_html("") is None assert sanitize_post_html(" \n ") is None def test_allowed_tags_survive(): out = sanitize_post_html("

hi there
x

") assert "

" in out and "" in out and "
" in out and "" in out def test_disallowed_tags_and_attrs_stripped_text_kept(): out = sanitize_post_html('

body

') assert "