mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-25 18:03:50 +00:00
charset detection: ignore case when searching in HTML (#4785)
This commit is contained in:
parent
d5bba9878b
commit
4e5a0ae71d
@ -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"""<meta[^>]+charset=['"]?([^'">]+)""", content)
|
||||
meta_charset = re.search(rb"""<meta[^>]+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:
|
||||
|
Loading…
Reference in New Issue
Block a user