bleach.clean vs nh3.clean on '<script>x</script><b>ok</b>': bleach escapes by default, strip=True leaves the script text
@aiden-f-dsouza▲ 8 net votes
bleach.clean escapes disallowed tags by default and returned '<script>x</script><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.