diff options
author | Mirjam Friesen <[email protected]> | 2024-04-02 13:33:35 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2025-02-06 13:23:08 +0100 |
commit | 36f42a5e8bfb9ae1b991e3b6b92c85ce685e3301 (patch) | |
tree | 1492fd67e7af748ed77422bd2e7bf134bd9a67c1 | |
parent | 8e121d138c4f658cf0953eeeeea85d07c203a5b6 (diff) | |
download | cowboy-36f42a5e8bfb9ae1b991e3b6b92c85ce685e3301.tar.gz cowboy-36f42a5e8bfb9ae1b991e3b6b92c85ce685e3301.tar.bz2 cowboy-36f42a5e8bfb9ae1b991e3b6b92c85ce685e3301.zip |
Fix cowboy_req:filter_cookies missing valid cookies
When 3 or more cookies were sent the extra cookies were not
found because the binary:split on ";" stopped at the first
occurrence.
-rw-r--r-- | src/cowboy_req.erl | 2 | ||||
-rw-r--r-- | test/req_SUITE.erl | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/cowboy_req.erl b/src/cowboy_req.erl index 3f87677..8d8cf82 100644 --- a/src/cowboy_req.erl +++ b/src/cowboy_req.erl @@ -462,7 +462,7 @@ filter_cookies(Names0, Req=#{headers := Headers}) -> case header(<<"cookie">>, Req) of undefined -> Req; Value0 -> - Cookies0 = binary:split(Value0, <<$;>>), + Cookies0 = binary:split(Value0, <<$;>>, [global]), Cookies = lists:filter(fun(Cookie) -> lists:member(cookie_name(Cookie), Names) end, Cookies0), diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl index 9036cac..f6208a2 100644 --- a/test/req_SUITE.erl +++ b/test/req_SUITE.erl @@ -324,7 +324,7 @@ filter_then_parse_cookies(Config) -> [{<<"cookie">>, "bad name=strawberry"}], Config), <<"[{<<\"cake\">>,<<\"strawberry\">>}]">> = do_get_body("/filter_then_parse_cookies", - [{<<"cookie">>, "bad name=strawberry; cake=strawberry"}], Config), + [{<<"cookie">>, "bad name=strawberry; another bad name=strawberry; cake=strawberry"}], Config), <<"[]">> = do_get_body("/filter_then_parse_cookies", [{<<"cookie">>, "Blocked by http://www.example.com/upgrade-to-remove"}], Config), |