From 4e5a0ae71d3a4ecdb6e0f8a102010d60e06cedae Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 31 Aug 2021 11:13:28 +0200 Subject: [PATCH] charset detection: ignore case when searching in HTML (#4785) --- mitmproxy/http.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mitmproxy/http.py b/mitmproxy/http.py index eae4eeb7e..bc1f6c68a 100644 --- a/mitmproxy/http.py +++ b/mitmproxy/http.py @@ -408,13 +408,13 @@ class Message(serializable.Serializable): if "json" in self.headers.get("content-type", ""): enc = "utf8" if not enc: - meta_charset = re.search(rb"""]+charset=['"]?([^'">]+)""", content) + meta_charset = re.search(rb"""]+charset=['"]?([^'">]+)""", content, re.IGNORECASE) if meta_charset: enc = meta_charset.group(1).decode("ascii", "ignore") if not enc: if "text/css" in self.headers.get("content-type", ""): # @charset rule must be the very first thing. - css_charset = re.match(rb"""@charset "([^"]+)";""", content) + css_charset = re.match(rb"""@charset "([^"]+)";""", content, re.IGNORECASE) if css_charset: enc = css_charset.group(1).decode("ascii", "ignore") if not enc: