From: Florian Best Date: Fri, 1 Oct 2021 22:42:04 +0000 (+0200) Subject: fix[web]: fix optional whitespace parsing of Accept-Language header X-Git-Tag: v6.2.0b1~35^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=797e5a88b4299ca523de720aeb8b2e5a6a7e41f0;p=thirdparty%2Ftornado.git fix[web]: fix optional whitespace parsing of Accept-Language header HTTP allows OWS between parameters: `Accept-Language: de-DE; q=0.1, en-US; q=0.2` --- diff --git a/tornado/web.py b/tornado/web.py index ddf1de746..b3efce998 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -1286,9 +1286,9 @@ class RequestHandler(object): locales = [] for language in languages: parts = language.strip().split(";") - if len(parts) > 1 and parts[1].startswith("q="): + if len(parts) > 1 and parts[1].strip().startswith("q="): try: - score = float(parts[1][2:]) + score = float(parts[1].strip()[2:]) except (ValueError, TypeError): score = 0.0 else: