Browse Source

Remove the obsolete Version cookie attribute

Sebastian Strollo 3 years ago
parent
commit
7ceed650df
1 changed files with 8 additions and 10 deletions
  1. 8 10
      src/cow_cookie.erl

+ 8 - 10
src/cow_cookie.erl

@@ -351,7 +351,7 @@ setcookie(Name, Value, Opts) ->
 			<<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]),
 			<<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]),
 	nomatch = binary:match(iolist_to_binary(Value), [<<$,>>, <<$;>>,
 	nomatch = binary:match(iolist_to_binary(Value), [<<$,>>, <<$;>>,
 			<<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]),
 			<<$\s>>, <<$\t>>, <<$\r>>, <<$\n>>, <<$\013>>, <<$\014>>]),
-	[Name, <<"=">>, Value, <<"; Version=1">>, attributes(maps:to_list(Opts))].
+	[Name, <<"=">>, Value, attributes(maps:to_list(Opts))].
 
 
 attributes([]) -> [];
 attributes([]) -> [];
 attributes([{domain, Domain}|Tail]) -> [<<"; Domain=">>, Domain|attributes(Tail)];
 attributes([{domain, Domain}|Tail]) -> [<<"; Domain=">>, Domain|attributes(Tail)];
@@ -381,26 +381,26 @@ setcookie_test_() ->
 	Tests = [
 	Tests = [
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{http_only => true, domain => <<"acme.com">>},
 			#{http_only => true, domain => <<"acme.com">>},
-			<<"Customer=WILE_E_COYOTE; Version=1; "
+			<<"Customer=WILE_E_COYOTE; "
 				"Domain=acme.com; HttpOnly">>},
 				"Domain=acme.com; HttpOnly">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{path => <<"/acme">>},
 			#{path => <<"/acme">>},
-			<<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>},
+			<<"Customer=WILE_E_COYOTE; Path=/acme">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{secure => true},
 			#{secure => true},
-			<<"Customer=WILE_E_COYOTE; Version=1; Secure">>},
+			<<"Customer=WILE_E_COYOTE; Secure">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{secure => false, http_only => false},
 			#{secure => false, http_only => false},
-			<<"Customer=WILE_E_COYOTE; Version=1">>},
+			<<"Customer=WILE_E_COYOTE">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{same_site => lax},
 			#{same_site => lax},
-			<<"Customer=WILE_E_COYOTE; Version=1; SameSite=Lax">>},
+			<<"Customer=WILE_E_COYOTE; SameSite=Lax">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{same_site => strict},
 			#{same_site => strict},
-			<<"Customer=WILE_E_COYOTE; Version=1; SameSite=Strict">>},
+			<<"Customer=WILE_E_COYOTE; SameSite=Strict">>},
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 		{<<"Customer">>, <<"WILE_E_COYOTE">>,
 			#{path => <<"/acme">>, badoption => <<"negatory">>},
 			#{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}
 	[{R, fun() -> R = iolist_to_binary(setcookie(N, V, O)) end}
 		|| {N, V, O, R} <- Tests].
 		|| {N, V, O, R} <- Tests].
@@ -411,7 +411,6 @@ setcookie_max_age_test() ->
 			setcookie(N, V, O)), <<";">>, [global])
 			setcookie(N, V, O)), <<";">>, [global])
 	end,
 	end,
 	[<<"Customer=WILE_E_COYOTE">>,
 	[<<"Customer=WILE_E_COYOTE">>,
-		<<" Version=1">>,
 		<<" Expires=", _/binary>>,
 		<<" Expires=", _/binary>>,
 		<<" Max-Age=111">>,
 		<<" Max-Age=111">>,
 		<<" Secure">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>,
 		<<" Secure">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>,
@@ -420,7 +419,6 @@ setcookie_max_age_test() ->
 		{'EXIT', {{badarg, {max_age, -111}}, _}} -> ok
 		{'EXIT', {{badarg, {max_age, -111}}, _}} -> ok
 	end,
 	end,
 	[<<"Customer=WILE_E_COYOTE">>,
 	[<<"Customer=WILE_E_COYOTE">>,
-		<<" Version=1">>,
 		<<" Expires=", _/binary>>,
 		<<" Expires=", _/binary>>,
 		<<" Max-Age=86417">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>,
 		<<" Max-Age=86417">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>,
 			 #{max_age => 86417}),
 			 #{max_age => 86417}),