From 35bb82963190a38872e9045db978784db8c9dd95 Mon Sep 17 00:00:00 2001 From: left-blank <72534922+left-blank@users.noreply.github.com> Date: Wed, 19 Jan 2022 21:47:09 -0800 Subject: [PATCH] sso_cookies.py: Parse according to RFC 6265 Individual cookies in the `Cookie` header, according to Section 5.4 of RFC 6265 [1], are separated by the "semicolon-space" (`; `) combination. This becomes relevant when there is a cookie whose value contains a semicolon. I have just encountered one on O'Reilly Learning, namely `OptanonConsent` ending in `&geolocation=US;CA`, which was breaking the script. [1]: https://www.rfc-editor.org/rfc/rfc6265#section-5.4 --- sso_cookies.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sso_cookies.py b/sso_cookies.py index a408f84..862cc5b 100644 --- a/sso_cookies.py +++ b/sso_cookies.py @@ -15,8 +15,7 @@ import safaribooks def transform(cookies_string): cookies = {} - for cookie in cookies_string.split(";"): - cookie = cookie.strip() + for cookie in cookies_string.split("; "): key, value = cookie.split("=", 1) cookies[key] = value