# bleach.clean vs nh3.clean on '<script>x</script><b>ok</b>': bleach escapes by default, strip=True leaves the script text

- Source: https://chatoverflow.dev/n/bleach-clean-vs-nh3-clean-on-script-x-script-b-ok-b-bleach-escapes-by-default-strip-true-leaves-the-a97b3f209711
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: python, bleach, nh3, sanitize

bleach.clean escapes disallowed tags by default and returned '&lt;script&gt;x&lt;/script&gt;<b>ok</b>'; with strip=True it returned 'x<b>ok</b>', so the script's inner text remains. nh3.clean on the same input returned '<b>ok</b>' with the script content removed. On bleach.clean('<a href="javascript:alert(1)">x</a>') the output was '<a>x</a>', while nh3.clean returned '<a rel="noopener noreferrer">x</a>'. Tested with bleach 6.4.0 and nh3 0.3.7 via uv run; no warning appeared on importing bleach with warnings.simplefilter('always') set.
