aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/test/uri_SUITE.erl
diff options
context:
space:
mode:
authorLuca Favatella <[email protected]>2018-03-06 14:01:12 +0000
committerLuca Favatella <[email protected]>2018-03-14 12:46:47 +0000
commit8df97eea992cf0fd3f1f1fc9f6bbc609949f1355 (patch)
treed7dcd5246b77d3240c51bc348c1dda8a95606919 /lib/inets/test/uri_SUITE.erl
parent98d8d18584cffd9bae18f1f9be997ab00fac081e (diff)
downloadotp-8df97eea992cf0fd3f1f1fc9f6bbc609949f1355.tar.gz
otp-8df97eea992cf0fd3f1f1fc9f6bbc609949f1355.tar.bz2
otp-8df97eea992cf0fd3f1f1fc9f6bbc609949f1355.zip
inets: fix scheme validation in http_uri:parse when binary URI
Diffstat (limited to 'lib/inets/test/uri_SUITE.erl')
-rw-r--r--lib/inets/test/uri_SUITE.erl21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/inets/test/uri_SUITE.erl b/lib/inets/test/uri_SUITE.erl
index f973296af6..8e00e6f565 100644
--- a/lib/inets/test/uri_SUITE.erl
+++ b/lib/inets/test/uri_SUITE.erl
@@ -52,6 +52,7 @@ all() ->
escaped,
hexed_query,
scheme_validation,
+ scheme_validation_bin,
encode_decode
].
@@ -273,6 +274,26 @@ scheme_validation(Config) when is_list(Config) ->
http_uri:parse("https://localhost#fragment",
[{scheme_validation_fun, none}]).
+scheme_validation_bin(Config) when is_list(Config) ->
+ {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<>>}} =
+ http_uri:parse(<<"http://localhost#fragment">>),
+
+ ValidationFun =
+ fun(<<"http">>) -> valid;
+ (_) -> {error, bad_scheme}
+ end,
+
+ {ok, {http,<<>>,<<"localhost">>,80,<<"/">>,<<>>}} =
+ http_uri:parse(<<"http://localhost#fragment">>,
+ [{scheme_validation_fun, ValidationFun}]),
+ {error, bad_scheme} =
+ http_uri:parse(<<"https://localhost#fragment">>,
+ [{scheme_validation_fun, ValidationFun}]),
+ %% non-fun scheme_validation_fun works as no option passed
+ {ok, {https,<<>>,<<"localhost">>,443,<<"/">>,<<>>}} =
+ http_uri:parse(<<"https://localhost#fragment">>,
+ [{scheme_validation_fun, none}]).
+
encode_decode(Config) when is_list(Config) ->
?assertEqual("foo%20bar", http_uri:encode("foo bar")),
?assertEqual(<<"foo%20bar">>, http_uri:encode(<<"foo bar">>)),