Moving from beach to nh3

2023-06-20 10:05 AM

#python #webapp #dev #code #text input

I happened to see a post about bleach, a text input santization library, deprecated in January. I have a couple of apps which use this library to strip out HTML tags which can be used to do mean things and I needed to make some updates.

Luckily, there's a new project, nh3 which made this super painless. It's a Python wrapper for a Rust library which performs the same task super easily.

I wasn't actually using bleach in my projects - I was using bleach_extras which allowed me to strip the content within the tags, not just the tags themselves. nh3 provides this out of the box. Here's what the original function looked like:

```python

import bleach_extras

string = "

This is a