From ce9aff19f036310dd33d00d14cff35a559b8ccb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 29 Sep 2012 13:03:45 +0200 Subject: Remove the urldecode cowboy_protocol option This allows inconsistent behavior and is not used enough to be supported. --- src/cowboy_http.erl | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/cowboy_http.erl') diff --git a/src/cowboy_http.erl b/src/cowboy_http.erl index 6ba4834..e0b1632 100644 --- a/src/cowboy_http.erl +++ b/src/cowboy_http.erl @@ -47,7 +47,7 @@ -export([urldecode/2]). -export([urlencode/1]). -export([urlencode/2]). --export([x_www_form_urlencoded/2]). +-export([x_www_form_urlencoded/1]). -type version() :: {Major::non_neg_integer(), Minor::non_neg_integer()}. -type headers() :: [{binary(), iodata()}]. @@ -861,15 +861,14 @@ tohexu(C) when C < 17 -> $A + C - 10. tohexl(C) when C < 10 -> $0 + C; tohexl(C) when C < 17 -> $a + C - 10. --spec x_www_form_urlencoded(binary(), fun((binary()) -> binary())) -> - list({binary(), binary() | true}). -x_www_form_urlencoded(<<>>, _URLDecode) -> +-spec x_www_form_urlencoded(binary()) -> list({binary(), binary() | true}). +x_www_form_urlencoded(<<>>) -> []; -x_www_form_urlencoded(Qs, URLDecode) -> +x_www_form_urlencoded(Qs) -> Tokens = binary:split(Qs, <<"&">>, [global, trim]), [case binary:split(Token, <<"=">>) of - [Token] -> {URLDecode(Token), true}; - [Name, Value] -> {URLDecode(Name), URLDecode(Value)} + [Token] -> {urldecode(Token), true}; + [Name, Value] -> {urldecode(Name), urldecode(Value)} end || Token <- Tokens]. %% Tests. @@ -1053,9 +1052,7 @@ x_www_form_urlencoded_test_() -> {<<"a=b=c=d=e&f=g">>, [{<<"a">>, <<"b=c=d=e">>}, {<<"f">>, <<"g">>}]}, {<<"a+b=c+d">>, [{<<"a b">>, <<"c d">>}]} ], - URLDecode = fun urldecode/1, - [{Qs, fun() -> R = x_www_form_urlencoded( - Qs, URLDecode) end} || {Qs, R} <- Tests]. + [{Qs, fun() -> R = x_www_form_urlencoded(Qs) end} || {Qs, R} <- Tests]. urldecode_test_() -> U = fun urldecode/2, -- cgit v1.2.3