From 6074ce4a39fc4522e7a046bd1fd1921ed2ff34b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 13 Dec 2012 16:54:07 +0100 Subject: Add missing quotes to quoting for cookie values --- src/cowboy_http.erl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index fb9f21c..44984e0 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -845,11 +845,11 @@ cookie_to_iodata(Name, Value, Opts) -> -spec quote(binary()) -> binary(). quote(Bin) -> - quote(Bin, <<>>). + quote(Bin, << $" >>). -spec quote(binary(), binary()) -> binary(). quote(<<>>, Acc) -> - Acc; + << Acc/binary, $" >>; quote(<< $", Rest/bits >>, Acc) -> quote(Rest, << Acc/binary, $\\, $" >>); quote(<< C, Rest/bits >>, Acc) -> @@ -1160,14 +1160,14 @@ cookie_to_iodata_test_() -> Tests = [ {<<"Customer">>, <<"WILE_E_COYOTE">>, [{http_only, true}, {domain, <<"acme.com">>}], - <<"Customer=WILE_E_COYOTE; Version=1; " - "Domain=acme.com; HttpOnly">>}, + <<"Customer=\"WILE_E_COYOTE\"; Version=1; " + "Domain=\"acme.com\"; HttpOnly">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, [{path, <<"/acme">>}], - <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>}, + <<"Customer=\"WILE_E_COYOTE\"; Version=1; Path=\"/acme\"">>}, {<<"Customer">>, <<"WILE_E_COYOTE">>, [{path, <<"/acme">>}, {badoption, <<"negatory">>}], - <<"Customer=WILE_E_COYOTE; Version=1; Path=/acme">>} + <<"Customer=\"WILE_E_COYOTE\"; Version=1; Path=\"/acme\"">>} ], [{R, fun() -> R = iolist_to_binary(cookie_to_iodata(N, V, O)) end} || {N, V, O, R} <- Tests]. @@ -1177,7 +1177,7 @@ cookie_to_iodata_max_age_test() -> binary:split(iolist_to_binary( cookie_to_iodata(N, V, O)), <<";">>, [global]) end, - [<<"Customer=WILE_E_COYOTE">>, + [<<"Customer=\"WILE_E_COYOTE\"">>, <<" Version=1">>, <<" Expires=", _/binary>>, <<" Max-Age=111">>, @@ -1186,7 +1186,7 @@ cookie_to_iodata_max_age_test() -> case catch F(<<"Customer">>, <<"WILE_E_COYOTE">>, [{max_age, -111}]) of {'EXIT', {{case_clause, {max_age, -111}}, _}} -> ok end, - [<<"Customer=WILE_E_COYOTE">>, + [<<"Customer=\"WILE_E_COYOTE\"">>, <<" Version=1">>, <<" Expires=", _/binary>>, <<" Max-Age=86417">>] = F(<<"Customer">>, <<"WILE_E_COYOTE">>, -- cgit v1.2.3