aboutsummaryrefslogtreecommitdiffstats
path: root/src/cowboy_http.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-12-13 16:54:07 +0100
committerLoïc Hoguin <[email protected]>2012-12-13 16:57:58 +0100
commit6074ce4a39fc4522e7a046bd1fd1921ed2ff34b4 (patch)
treea6c84ef290d76f02c2cc48ac8b9600e284a5d5aa /src/cowboy_http.erl
parentea7af4b72444890df8cafc624ecdf7e32f7a62cb (diff)
downloadcowboy-6074ce4a39fc4522e7a046bd1fd1921ed2ff34b4.tar.gz
cowboy-6074ce4a39fc4522e7a046bd1fd1921ed2ff34b4.tar.bz2
cowboy-6074ce4a39fc4522e7a046bd1fd1921ed2ff34b4.zip
Add missing quotes to quoting for cookie values
Diffstat (limited to 'src/cowboy_http.erl')
-rw-r--r--src/cowboy_http.erl16
1 files changed, 8 insertions, 8 deletions
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">>,