aboutsummaryrefslogtreecommitdiff
path: root/src/utils/http.py
diff options
context:
space:
mode:
authorGravatar jesopo2020-02-06 11:54:04 +0000
committerGravatar jesopo2020-02-06 11:54:04 +0000
commit01441efe7564e31e465c84377518ec33176fb893 (patch)
treeaa0fc4272b810927fdc307e4ab70a4f8dd6eb80b /src/utils/http.py
parentchghost events no longer have 'username'/'hostname' kwargs (diff)
signature
only pull 'charset' from <meta> content-type when it definitely exists
Diffstat (limited to 'src/utils/http.py')
-rw-r--r--src/utils/http.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/utils/http.py b/src/utils/http.py
index f5595a2a..239ae11a 100644
--- a/src/utils/http.py
+++ b/src/utils/http.py
@@ -153,7 +153,9 @@ def _find_encoding(headers: typing.Dict[str, str], data: bytes
meta_content_type = soup.findAll("meta",
{"http-equiv": lambda v: (v or "").lower() == "content-type"})
if meta_content_type:
- return _split_content(meta_content_type[0].get("content"))["charset"]
+ meta_content = _split_content(meta_content_type[0].get("content"))
+ if "charset" in meta_content:
+ return meta_content["charset"]
doctype = [item for item in soup.contents if isinstance(item,
bs4.Doctype)] or None