From 6122aea7fd89d042f44c742f8711e04f28a015ef Mon Sep 17 00:00:00 2001 From: Mirjam Friesen Date: Tue, 2 Apr 2024 13:33:35 +0200 Subject: [PATCH] Fix cookie filter --- src/cowboy_req.erl | 2 +- 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 3f8767772..8d8cf8295 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 9036cac9c..f6208a202 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),