fix: content encoding inference from meta tag, especially for various unusual format by edenw97 · Pull Request #8031 · mitmproxy/mitmproxy

mhils

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

match = meta_charset.group(2) or meta_charset.group(3)
if match:
enc = match.decode("ascii", "ignore").strip()
else:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already validated that meta_charset is not None, so can this case ever happen?

(charset="" would be an option, but then we should move the .strip() before the if as well)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, do you mean move the strip() to before the decode?