diff --git a/sanic/headers.py b/sanic/headers.py index 9ef28fa3..3a375644 100644 --- a/sanic/headers.py +++ b/sanic/headers.py @@ -1,17 +1,17 @@ import re token, quoted = r"([\w!#$%&'*+\-.^_`|~]+)", r'"((?:[^"]|\\")*)"' -parameter = re.compile(fr';\s*{token}=(?:{token}|{quoted})', re.ASCII) +parameter = re.compile(fr";\s*{token}=(?:{token}|{quoted})", re.ASCII) def parse_options_header(value: str): """Parse HTTP header values of Content-Type format.""" - pos = value.find(';') + pos = value.find(";") if pos == -1: options = {} else: options = { - m.group(1).lower(): m.group(2) or m.group(3).replace(r'\"', '"') + m.group(1).lower(): m.group(2) or m.group(3).replace('\\"', '"') for m in parameter.finditer(value[pos:]) } value = value[:pos]