diff options
author | Marcus Arendt <[email protected]> | 2015-01-26 13:03:07 +0100 |
---|---|---|
committer | Marcus Arendt <[email protected]> | 2015-01-26 13:03:07 +0100 |
commit | bb6d1557403f64b35c1d41a8ec6ab83360904c3d (patch) | |
tree | 82788997f94b9fd9dcfe5d2187617723b84f30e8 /lib/inets/src | |
parent | f3dc028801a299710001a53553366baba4d40587 (diff) | |
parent | b7b36d9c0519b5c7f44a8a66cd823191a44c105d (diff) | |
download | otp-bb6d1557403f64b35c1d41a8ec6ab83360904c3d.tar.gz otp-bb6d1557403f64b35c1d41a8ec6ab83360904c3d.tar.bz2 otp-bb6d1557403f64b35c1d41a8ec6ab83360904c3d.zip |
Merge branch 'maint'
Diffstat (limited to 'lib/inets/src')
-rw-r--r-- | lib/inets/src/http_client/httpc_cookie.erl | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/inets/src/http_client/httpc_cookie.erl b/lib/inets/src/http_client/httpc_cookie.erl index 134115bdfa..5d71a0bb8f 100644 --- a/lib/inets/src/http_client/httpc_cookie.erl +++ b/lib/inets/src/http_client/httpc_cookie.erl @@ -334,9 +334,23 @@ add_domain(Str, #http_cookie{domain_default = true}) -> add_domain(Str, #http_cookie{domain = Domain}) -> Str ++ "; $Domain=" ++ Domain. +is_set_cookie_valid("") -> + %% an empty Set-Cookie header is not valid + false; +is_set_cookie_valid([$=|_]) -> + %% a Set-Cookie header without name is not valid + false; +is_set_cookie_valid(SetCookieHeader) -> + %% a Set-Cookie header without name/value is not valid + case string:chr(SetCookieHeader, $=) of + 0 -> false; + _ -> true + end. + parse_set_cookies(CookieHeaders, DefaultPathDomain) -> - %% empty Set-Cookie header is invalid according to RFC but some sites violate it - SetCookieHeaders = [Value || {"set-cookie", Value} <- CookieHeaders, Value /= ""], + %% filter invalid Set-Cookie headers + SetCookieHeaders = [Value || {"set-cookie", Value} <- CookieHeaders, + is_set_cookie_valid(Value)], Cookies = [parse_set_cookie(SetCookieHeader, DefaultPathDomain) || SetCookieHeader <- SetCookieHeaders], %% print_cookies("Parsed Cookies", Cookies), |