There are sequences that don't get filtered by that. Aside from the usual things like \r or \b, it looks like https://man7.org/linux/man-pages/man4/console_codes.4.html lists a few codes that defy it too. While that diff above might be the "stackoverflow answer", it doesn't seem complete.
Instead, why not just adopt a whitelist policy? Only allow visible and space characters, or something like that.
I'm not convinced that really cuts it. Namely, from the diff:
- print(" %s" % (info[" description" ] or "")) r"(\x9B| \x1B\[) [0-?]*[ -/]*[@-~]",
+ # strip ANSI escape sequences
+ description = re.sub(
+ "", info["description"] or "")
+
+ print(" %s" % description)
There are sequences that don't get filtered by that. Aside from the usual things like \r or \b, it looks like https:/ /man7.org/ linux/man- pages/man4/ console_ codes.4. html lists a few codes that defy it too. While that diff above might be the "stackoverflow answer", it doesn't seem complete.
Instead, why not just adopt a whitelist policy? Only allow visible and space characters, or something like that.