From 7ceed650df638775e09bc032910fc8f527b32945 Mon Sep 17 00:00:00 2001 From: Sebastian Strollo Date: Mon, 15 Nov 2021 16:42:28 +0100 Subject: Remove the obsolete Version cookie attribute --- src/cow_cookie.erl | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/cow_cookie.erl') diff --git a/src/cow_cookie.erl b/src/cow_cookie.erl index 953cc25..28c93ff 100644 --- a/src/cow_cookie.erl +++ b/src/cow_cookie.erl @@ -351,7 +351,7 @@ setcookie(Name, Value, Opts) -> <<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]), nomatch = binary:match(iolist_to_binary(Value), [<<$,>>, <<$;>>, <<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]), - [Name, <<"=">>, Value, <<"; Version=1">>, attributes(maps:to_list(Opts))]. + [Name, <<"=">>, Value, attributes(maps:to_list(Opts))]. attributes([]) -> []; attributes([{domain, Domain}|Tail]) -> [<<"; Domain=">>, Domain|attributes(Tail)]; @@ -381,26 +381,26 @@ setcookie_test_() -> Tests = [ {<<"Customer">>, <<"WILE_E_COYOTE">>, #{http_only => true, domain => <<"acme.com">>}, - <<"Customer=WILE_E_COYOTE; Version=1; " + <<"Customer=WILE_E_COYOTE; " "Domain=acme.com; HttpOnly">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{path => <<"/acme">>}, - <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>}, + <<"Customer=WILE_E_COYOTE; Path=/acme">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{secure => true}, - <<"Customer=WILE_E_COYOTE; Version=1; Secure">>}, + <<"Customer=WILE_E_COYOTE; Secure">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{secure => false, http_only => false}, - <<"Customer=WILE_E_COYOTE; Version=1">>}, + <<"Customer=WILE_E_COYOTE">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{same_site => lax}, - <<"Customer=WILE_E_COYOTE; Version=1; SameSite=Lax">>}, + <<"Customer=WILE_E_COYOTE; SameSite=Lax">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{same_site => strict}, - <<"Customer=WILE_E_COYOTE; Version=1; SameSite=Strict">>}, + <<"Customer=WILE_E_COYOTE; SameSite=Strict">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, #{path => <<"/acme">>, badoption => <<"negatory">>}, - <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>} + <<"Customer=WILE_E_COYOTE; Path=/acme">>} ], [{R, fun() -> R = iolist_to_binary(setcookie(N, V, O)) end} || {N, V, O, R} <- Tests]. @@ -411,7 +411,6 @@ setcookie_max_age_test() -> setcookie(N, V, O)), <<";">>, [global]) end, [<<"Customer=WILE_E_COYOTE">>, - <<" Version=1">>, <<" Expires=", _/binary>>, <<" Max-Age=111">>, <<" Secure">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>, @@ -420,7 +419,6 @@ setcookie_max_age_test() -> {'EXIT', {{badarg, {max_age, -111}}, _}} -> ok end, [<<"Customer=WILE_E_COYOTE">>, - <<" Version=1">>, <<" Expires=", _/binary>>, <<" Max-Age=86417">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>, #{max_age => 86417}), -- cgit v1.2.3