mime: fix issue with charset param

exec
dece 3 years ago
parent 4738e495b2
commit 8e4f8c4c70

@ -2,7 +2,6 @@ TODO
---------------------------------------- ----------------------------------------
dumb rendering mode per site dumb rendering mode per site
well, preferences per site maybe? well, preferences per site maybe?
does encoding really work? cf. egsam
more UT more UT
setup.py setup.py

@ -25,9 +25,9 @@ class MimeType:
def from_str(mime_string) -> Optional["MimeType"]: def from_str(mime_string) -> Optional["MimeType"]:
"""Parse a MIME string into a MimeType instance, or None on error.""" """Parse a MIME string into a MimeType instance, or None on error."""
if ";" in mime_string: if ";" in mime_string:
type_str, *parameters = mime_string.split(";") type_str, *param_strs = mime_string.split(";")
parameters = {} parameters = {}
for param in map(lambda s: s.strip().lower(), parameters): for param in map(lambda s: s.strip().lower(), param_strs):
if param.count("=") != 1: if param.count("=") != 1:
return None return None
param_name, param_value = param.split("=") param_name, param_value = param.split("=")

Loading…
Cancel
Save