diff options
author | Péter Dimitrov <[email protected]> | 2017-10-16 13:30:36 +0200 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2017-10-23 15:53:29 +0200 |
commit | 57f8021105f1c213be674681f48d0c8e92935ff6 (patch) | |
tree | 58360c252322216e5afd883f9fe27b5a9c1aa620 | |
parent | 4a2358bbf4a4049a765aab435a31daeeffbbd677 (diff) | |
download | otp-57f8021105f1c213be674681f48d0c8e92935ff6.tar.gz otp-57f8021105f1c213be674681f48d0c8e92935ff6.tar.bz2 otp-57f8021105f1c213be674681f48d0c8e92935ff6.zip |
stdlib: Change handling of queries ["?" query]
Previously when parsing queries the first "?" was part of the
parsed query in the result Map. This behavior has been changed
to follow the patterns used with other URI components and to
not include the special character(s) that mark the start of a
specific component.
-rw-r--r-- | lib/stdlib/src/uri_string.erl | 80 | ||||
-rw-r--r-- | lib/stdlib/test/property_test/uri_string_recompose.erl | 2 | ||||
-rw-r--r-- | lib/stdlib/test/uri_string_SUITE.erl | 97 |
3 files changed, 93 insertions, 86 deletions
diff --git a/lib/stdlib/src/uri_string.erl b/lib/stdlib/src/uri_string.erl index 439ffa80da..f9e1e273bc 100644 --- a/lib/stdlib/src/uri_string.erl +++ b/lib/stdlib/src/uri_string.erl @@ -466,9 +466,9 @@ parse_relative_part(?STRING_REST($/, Rest), URI) -> URI1#{path => decode_path(?STRING_REST($/, Path))}; parse_relative_part(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), + Query = calculate_parsed_query(Rest, T), URI2 = maybe_add_path(URI1), - URI2#{query => decode_query(?STRING_REST($?, Query))}; + URI2#{query => decode_query(Query)}; parse_relative_part(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), % path-empty Fragment = calculate_parsed_fragment(Rest, T), @@ -521,8 +521,8 @@ parse_segment(?STRING_REST($/, Rest), URI) -> parse_segment(Rest, URI); % segment parse_segment(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_segment(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), Fragment = calculate_parsed_fragment(Rest, T), @@ -544,8 +544,8 @@ parse_segment_nz_nc(?STRING_REST($/, Rest), URI) -> parse_segment(Rest, URI); % segment parse_segment_nz_nc(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_segment_nz_nc(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), Fragment = calculate_parsed_fragment(Rest, T), @@ -595,14 +595,6 @@ parse_scheme_start(?STRING_REST(Char, Rest), URI) -> %% According to the URI specification there is always a %% path component in every URI-reference and it can be %% empty. - -%% maybe_add_path(Map) -> -%% case length(maps:keys(Map)) of -%% 0 -> -%% Map#{path => <<>>}; -%% _Else -> -%% Map -%% end. maybe_add_path(Map) -> case maps:is_key(path, Map) of false -> @@ -659,8 +651,8 @@ parse_hier(?STRING_REST($/, Rest), URI) -> {Rest, URI1#{path => decode_path(?STRING_REST($/, Path))}}; parse_hier(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_hier(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), % path-empty Fragment = calculate_parsed_fragment(Rest, T), @@ -776,8 +768,8 @@ parse_host(?STRING_REST($/, Rest), URI) -> {Rest, URI1#{path => decode_path(?STRING_REST($/, Path))}}; parse_host(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_host(?STRING_REST($[, Rest), URI) -> parse_ipv6_bin(Rest, [], URI); parse_host(?STRING_REST($#, Rest), URI) -> @@ -805,8 +797,8 @@ parse_reg_name(?STRING_REST($/, Rest), URI) -> {Rest, URI1#{path => decode_path(?STRING_REST($/, Path))}}; parse_reg_name(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_reg_name(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), % path-empty Fragment = calculate_parsed_fragment(Rest, T), @@ -840,8 +832,8 @@ parse_ipv4_bin(?STRING_REST($/, Rest), Acc, URI) -> parse_ipv4_bin(?STRING_REST($?, Rest), Acc, URI) -> _ = validate_ipv4_address(lists:reverse(Acc)), {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_ipv4_bin(?STRING_REST($#, Rest), Acc, URI) -> _ = validate_ipv4_address(lists:reverse(Acc)), {T, URI1} = parse_fragment(Rest, URI), % path-empty @@ -901,8 +893,8 @@ parse_ipv6_bin_end(?STRING_REST($/, Rest), URI) -> {Rest, URI1#{path => decode_path(?STRING_REST($/, Path))}}; parse_ipv6_bin_end(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_ipv6_bin_end(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), % path-empty Fragment = calculate_parsed_fragment(Rest, T), @@ -939,8 +931,8 @@ parse_port(?STRING_REST($/, Rest), URI) -> {Rest, URI1#{path => decode_path(?STRING_REST($/, Path))}}; parse_port(?STRING_REST($?, Rest), URI) -> {T, URI1} = parse_query(Rest, URI), % path-empty ?query - Query = calculate_parsed_part(Rest, T), - {Rest, URI1#{query => decode_query(?STRING_REST($?, Query))}}; + Query = calculate_parsed_query(Rest, T), + {Rest, URI1#{query => decode_query(Query)}}; parse_port(?STRING_REST($#, Rest), URI) -> {T, URI1} = parse_fragment(Rest, URI), % path-empty Fragment = calculate_parsed_fragment(Rest, T), @@ -1090,7 +1082,7 @@ remove_brackets(Addr) -> Addr. %% Returns the parsed binary based on Input and the Unparsed part. %% Handles the following special cases: %% -%% #{host => [],path => "/",query => "?"} = uri_string:parse("///?") +%% #{host => [],path => "/",query => []} = uri_string:parse("///?") %% #{fragment => [],host => [],path => "/"} = uri_string:parse("///#") %% -spec calculate_parsed_part(binary(), binary()) -> binary(). @@ -1171,6 +1163,20 @@ calculate_parsed_port(Input, Unparsed) -> First. +calculate_parsed_query(<<$#>>, _) -> <<>>; +calculate_parsed_query(<<>>, _) -> <<>>; +calculate_parsed_query(Input, <<>>) -> + case binary:last(Input) of + $# -> + init_binary(Input); + _Else -> + Input + end; +calculate_parsed_query(Input, Unparsed) -> + {First, _} = split_binary(Input, byte_size(Input) - byte_size_exl_head(Unparsed)), + First. + + -spec calculate_parsed_fragment(binary(), binary()) -> binary(). calculate_parsed_fragment(<<$#>>, _) -> <<>>; calculate_parsed_fragment(Input, Unparsed) -> @@ -1183,10 +1189,10 @@ calculate_parsed_fragment(Input, Unparsed) -> %% %% Handles the following special cases: %% -%% #{host => "foo",query => "?"} = uri_string:parse("//foo?") +%% #{host => "foo",query => []} = uri_string:parse("//foo?") %% #{fragment => [],host => "foo"} = uri_string:parse("//foo#") %% #{host => "foo",path => "/"} = uri_string:parse("//foo/") -%% #{host => "foo",query => "?",scheme => "http"} = uri_string:parse("http://foo?") +%% #{host => "foo",query => [],scheme => "http"} = uri_string:parse("http://foo?") %% #{fragment => [],host => "foo",scheme => "http"} = uri_string:parse("http://foo#") %% #{host => "foo",path => "/",scheme => "http"} = uri_string:parse("http://foo/") %% @@ -1329,10 +1335,7 @@ encode_path(Cs) -> -spec encode_query(list()|binary()) -> list() | binary(). encode_query(Cs) -> - case validate_query(Cs) of - true -> encode(Cs, fun is_query/1); - false -> throw(uri_parse_error) - end. + encode(Cs, fun is_query/1). -spec encode_fragment(list()|binary()) -> list() | binary(). encode_fragment(Cs) -> @@ -1420,10 +1423,6 @@ validate_scheme(<<H, Rest/binary>>) -> false -> false end. -validate_query([$?|_]) -> true; -validate_query(<<$?/utf8, _/binary>>) -> true; -validate_query(_) -> false. - %%------------------------------------------------------------------------- %% Classifies hostname into the following categories: @@ -1582,7 +1581,7 @@ update_path(#{}, URI) -> update_query(#{query := Query}, empty) -> encode_query(Query); update_query(#{query := Query}, URI) -> - concat(URI,encode_query(Query)); + concat(URI,add_question_mark(encode_query(Query))); update_query(#{}, empty) -> empty; update_query(#{}, URI) -> @@ -1615,6 +1614,11 @@ add_hashmark(Comp) when is_binary(Comp) -> add_hashmark(Comp) when is_list(Comp) -> [$#|Comp]. +add_question_mark(Comp) when is_binary(Comp) -> + <<$?, Comp/binary>>; +add_question_mark(Comp) when is_list(Comp) -> + [$?|Comp]. + add_colon(Comp) when is_binary(Comp) -> <<$:, Comp/binary>>. diff --git a/lib/stdlib/test/property_test/uri_string_recompose.erl b/lib/stdlib/test/property_test/uri_string_recompose.erl index dad67cd4c1..97f9d727a0 100644 --- a/lib/stdlib/test/property_test/uri_string_recompose.erl +++ b/lib/stdlib/test/property_test/uri_string_recompose.erl @@ -271,7 +271,7 @@ port() -> query_map() -> - [$?| unicode()]. + unicode(). query_uri() -> diff --git a/lib/stdlib/test/uri_string_SUITE.erl b/lib/stdlib/test/uri_string_SUITE.erl index 83f702dd13..8a10948f32 100644 --- a/lib/stdlib/test/uri_string_SUITE.erl +++ b/lib/stdlib/test/uri_string_SUITE.erl @@ -52,7 +52,7 @@ -define(PORT_ENC, ":8042"). -define(PATH, "/där"). -define(PATH_ENC, "/d%C3%A4r"). --define(QUERY, "?name=örn"). +-define(QUERY, "name=örn"). -define(QUERY_ENC, "?name=%C3%B6rn"). -define(FRAGMENT, "näsa"). -define(FRAGMENT_ENC, "#n%C3%A4sa"). @@ -350,7 +350,7 @@ parse_binary_host_ipv4(_Config) -> #{host := <<"127.0.0.1">>} = uri_string:parse(<<"//127.0.0.1">>), #{host := <<"127.0.0.1">>, path := <<"/over/there">>} = uri_string:parse(<<"//127.0.0.1/over/there">>), - #{host := <<"127.0.0.1">>, query := <<"?name=ferret">>} = + #{host := <<"127.0.0.1">>, query := <<"name=ferret">>} = uri_string:parse(<<"//127.0.0.1?name=ferret">>), #{host := <<"127.0.0.1">>, fragment := <<"nose">>} = uri_string:parse(<<"//127.0.0.1#nose">>), uri_parse_error = (catch uri_string:parse(<<"//127.0.0.x">>)), @@ -362,7 +362,7 @@ parse_binary_host_ipv6(_Config) -> uri_string:parse(<<"//[2001:0db8:0000:0000:0000:0000:1428:07ab]">>), #{host := <<"::127.0.0.1">>, path := <<"/over/there">>} = uri_string:parse(<<"//[::127.0.0.1]/over/there">>), - #{host := <<"::127.0.0.1">>, query := <<"?name=ferret">>} = + #{host := <<"::127.0.0.1">>, query := <<"name=ferret">>} = uri_string:parse(<<"//[::127.0.0.1]?name=ferret">>), #{host := <<"::127.0.0.1">>, fragment := <<"nose">>} = uri_string:parse(<<"//[::127.0.0.1]#nose">>), @@ -397,35 +397,35 @@ parse_binary_path(_Config) -> uri_string:parse(<<"foo://example.com:8042/over/there">>). parse_binary_query(_Config) -> - #{scheme := <<"foo">>, query := <<"?name=ferret">>} = + #{scheme := <<"foo">>, query := <<"name=ferret">>} = uri_string:parse(<<"foo:?name=ferret">>), - #{scheme := <<"foo">>, path:= <<"over/there">>, query := <<"?name=ferret">>} = + #{scheme := <<"foo">>, path:= <<"over/there">>, query := <<"name=ferret">>} = uri_string:parse(<<"foo:over/there?name=ferret">>), - #{scheme := <<"foo">>, path:= <<"/over/there">>, query := <<"?name=ferret">>} = + #{scheme := <<"foo">>, path:= <<"/over/there">>, query := <<"name=ferret">>} = uri_string:parse(<<"foo:/over/there?name=ferret">>), - #{scheme := <<"foo">>, host := <<"example.com">>, query := <<"?name=ferret">>} = + #{scheme := <<"foo">>, host := <<"example.com">>, query := <<"name=ferret">>} = uri_string:parse(<<"foo://example.com?name=ferret">>), - #{scheme := <<"foo">>, host := <<"example.com">>, path := <<"/">>, query := <<"?name=ferret">>} = + #{scheme := <<"foo">>, host := <<"example.com">>, path := <<"/">>, query := <<"name=ferret">>} = uri_string:parse(<<"foo://example.com/?name=ferret">>), - #{query := <<"?name=ferret">>} = + #{path := <<>>, query := <<"name=ferret">>} = uri_string:parse(<<"?name=ferret">>), - #{path := <<"over/there">>, query := <<"?name=ferret">>} = + #{path := <<"over/there">>, query := <<"name=ferret">>} = uri_string:parse(<<"over/there?name=ferret">>), - #{path := <<"/">>, query := <<"?name=ferret">>} = + #{path := <<"/">>, query := <<"name=ferret">>} = uri_string:parse(<<"/?name=ferret">>), - #{path := <<"/over/there">>, query := <<"?name=ferret">>} = + #{path := <<"/over/there">>, query := <<"name=ferret">>} = uri_string:parse(<<"/over/there?name=ferret">>), - #{host := <<"example.com">>, query := <<"?name=ferret">>} = + #{host := <<"example.com">>, query := <<"name=ferret">>} = uri_string:parse(<<"//example.com?name=ferret">>), - #{host := <<"example.com">>, path := <<"/">>, query := <<"?name=ferret">>} = + #{host := <<"example.com">>, path := <<"/">>, query := <<"name=ferret">>} = uri_string:parse(<<"//example.com/?name=ferret">>). parse_binary_pct_encoded_query(_Config) -> #{scheme := <<"foo">>, host := <<"example.com">>, path := <<"/">>, - query := <<"?name=合気道"/utf8>>} = + query := <<"name=合気道"/utf8>>} = uri_string:parse(<<"foo://example.com/?name=%E5%90%88%E6%B0%97%E9%81%93">>), - #{host := <<"example.com">>, path := <<"/">>, query := <<"?name=合気道"/utf8>>} = + #{host := <<"example.com">>, path := <<"/">>, query := <<"name=合気道"/utf8>>} = uri_string:parse(<<"//example.com/?name=%E5%90%88%E6%B0%97%E9%81%93">>). parse_binary_fragment(_Config) -> @@ -520,7 +520,7 @@ parse_host_ipv4(_Config) -> #{host := "2001:0db8:0000:0000:0000:0000:1428:07ab"} = uri_string:parse("//[2001:0db8:0000:0000:0000:0000:1428:07ab]"), #{host := "127.0.0.1", path := "/over/there"} = uri_string:parse("//127.0.0.1/over/there"), - #{host := "127.0.0.1", query := "?name=ferret"} = uri_string:parse("//127.0.0.1?name=ferret"), + #{host := "127.0.0.1", query := "name=ferret"} = uri_string:parse("//127.0.0.1?name=ferret"), #{host := "127.0.0.1", fragment := "nose"} = uri_string:parse("//127.0.0.1#nose"), uri_parse_error = (catch uri_string:parse("//127.0.0.x")), uri_parse_error = (catch uri_string:parse("//1227.0.0.1")). @@ -528,7 +528,7 @@ parse_host_ipv4(_Config) -> parse_host_ipv6(_Config) -> #{host := "::127.0.0.1"} = uri_string:parse("//[::127.0.0.1]"), #{host := "::127.0.0.1", path := "/over/there"} = uri_string:parse("//[::127.0.0.1]/over/there"), - #{host := "::127.0.0.1", query := "?name=ferret"} = + #{host := "::127.0.0.1", query := "name=ferret"} = uri_string:parse("//[::127.0.0.1]?name=ferret"), #{host := "::127.0.0.1", fragment := "nose"} = uri_string:parse("//[::127.0.0.1]#nose"), uri_parse_error = (catch uri_string:parse("//[::127.0.0.x]")), @@ -560,35 +560,35 @@ parse_path(_Config) -> uri_string:parse("foo://example.com:8042/over/there"). parse_query(_Config) -> - #{scheme := "foo", query := "?name=ferret"} = + #{scheme := "foo", query := "name=ferret"} = uri_string:parse("foo:?name=ferret"), - #{scheme := "foo", path:= "over/there", query := "?name=ferret"} = + #{scheme := "foo", path:= "over/there", query := "name=ferret"} = uri_string:parse("foo:over/there?name=ferret"), - #{scheme := "foo", path:= "/over/there", query := "?name=ferret"} = + #{scheme := "foo", path:= "/over/there", query := "name=ferret"} = uri_string:parse("foo:/over/there?name=ferret"), - #{scheme := "foo", host := "example.com", query := "?name=ferret"} = + #{scheme := "foo", host := "example.com", query := "name=ferret"} = uri_string:parse("foo://example.com?name=ferret"), - #{scheme := "foo", host := "example.com", path := "/", query := "?name=ferret"} = + #{scheme := "foo", host := "example.com", path := "/", query := "name=ferret"} = uri_string:parse("foo://example.com/?name=ferret"), - #{query := "?name=ferret"} = + #{path := "", query := "name=ferret"} = uri_string:parse("?name=ferret"), - #{path := "over/there", query := "?name=ferret"} = + #{path := "over/there", query := "name=ferret"} = uri_string:parse("over/there?name=ferret"), - #{path := "/", query := "?name=ferret"} = + #{path := "/", query := "name=ferret"} = uri_string:parse("/?name=ferret"), - #{path := "/over/there", query := "?name=ferret"} = + #{path := "/over/there", query := "name=ferret"} = uri_string:parse("/over/there?name=ferret"), - #{host := "example.com", query := "?name=ferret"} = + #{host := "example.com", query := "name=ferret"} = uri_string:parse("//example.com?name=ferret"), - #{host := "example.com", path := "/", query := "?name=ferret"} = + #{host := "example.com", path := "/", query := "name=ferret"} = uri_string:parse("//example.com/?name=ferret"). parse_pct_encoded_query(_Config) -> #{scheme := "foo", host := "example.com", path := "/", - query := "?name=合気道"} = + query := "name=合気道"} = uri_string:parse("foo://example.com/?name=%E5%90%88%E6%B0%97%E9%81%93"), - #{host := "example.com", path := "/", query := "?name=合気道"} = + #{host := "example.com", path := "/", query := "name=合気道"} = uri_string:parse("//example.com/?name=%E5%90%88%E6%B0%97%E9%81%93"). parse_fragment(_Config) -> @@ -627,19 +627,19 @@ parse_pct_encoded_fragment(_Config) -> parse_list(_Config) -> #{scheme := "foo", path := "bar:nisse"} = uri_string:parse("foo:bar:nisse"), #{scheme := "foo", host := "example.com", port := 8042, - path := "/over/there", query := "?name=ferret", fragment := "nose"} = + path := "/over/there", query := "name=ferret", fragment := "nose"} = uri_string:parse("foo://example.com:8042/over/there?name=ferret#nose"), #{scheme := "foo", userinfo := "admin:admin", host := "example.com", port := 8042, - path := "/over/there", query := "?name=ferret", fragment := "nose"} = + path := "/over/there", query := "name=ferret", fragment := "nose"} = uri_string:parse("foo://admin:[email protected]:8042/over/there?name=ferret#nose"). parse_binary(_Config) -> #{scheme := <<"foo">>, path := <<"bar:nisse">>} = uri_string:parse(<<"foo:bar:nisse">>), #{scheme := <<"foo">>, host := <<"example.com">>, port := 8042, - path := <<"/over/there">>, query := <<"?name=ferret">>, fragment := <<"nose">>} = + path := <<"/over/there">>, query := <<"name=ferret">>, fragment := <<"nose">>} = uri_string:parse(<<"foo://example.com:8042/over/there?name=ferret#nose">>), #{scheme := <<"foo">>, userinfo := <<"admin:admin">>, host := <<"example.com">>, port := 8042, - path := <<"/over/there">>, query := <<"?name=ferret">>, fragment := <<"nose">>} = + path := <<"/over/there">>, query := <<"name=ferret">>, fragment := <<"nose">>} = uri_string:parse(<<"foo://admin:[email protected]:8042/over/there?name=ferret#nose">>). @@ -658,23 +658,26 @@ parse_relative(_Config) -> uri_string:parse(lists:append("fo",<<"o">>)). parse_special(_Config) -> - #{host := [],query := "?"} = uri_string:parse("//?"), + #{host := [],query := []} = uri_string:parse("//?"), #{fragment := [],host := []} = uri_string:parse("//#"), - #{host := [],query := "?",scheme := "foo"} = uri_string:parse("foo://?"), + #{host := [],query := [],scheme := "foo"} = uri_string:parse("foo://?"), #{fragment := [],host := [],scheme := "foo"} = uri_string:parse("foo://#"), #{host := <<>>, path := <<"/">>} = uri_string:parse(<<"///">>), #{host := <<"hostname">>} = uri_string:parse(<<"//hostname">>), #{host := <<>>, path := <<"/hostname">>} = uri_string:parse(<<"///hostname">>), - #{host := [],path := "/",query := "?"} = uri_string:parse("///?"), + #{host := [],path := "/",query := []} = uri_string:parse("///?"), #{fragment := [],host := [],path := "/"} = uri_string:parse("///#"), - #{host := "foo",query := "?"} = uri_string:parse("//foo?"), + #{host := "foo",query := []} = uri_string:parse("//foo?"), #{fragment := [],host := "foo"} = uri_string:parse("//foo#"), #{host := "foo",path := "/"} = uri_string:parse("//foo/"), - #{host := "foo",query := "?",scheme := "http"} = uri_string:parse("http://foo?"), + #{host := "foo",query := [],scheme := "http"} = uri_string:parse("http://foo?"), #{fragment := [],host := "foo",scheme := "http"} = uri_string:parse("http://foo#"), #{host := "foo",path := "/",scheme := "http"} = uri_string:parse("http://foo/"), #{fragment := [],host := "host",port := 80,scheme := "http"} = uri_string:parse("http://host:80#"), - #{host := "host",port := 80,query := "?",scheme := "http"} = uri_string:parse("http://host:80?"). + #{host := "host",port := 80,query := [],scheme := "http"} = uri_string:parse("http://host:80?"), + #{path := [],query := []} = uri_string:parse("?"), + #{path := [],query := "?"} = uri_string:parse("??"), + #{path := [],query := "??"} = uri_string:parse("???"). parse_special2(_Config) -> #{host := [],path := "/",port := 1,scheme := "a"} = uri_string:parse("a://:1/"), @@ -703,9 +706,9 @@ recompose_query(_Config) -> fragment => <<?FRAGMENT/utf8>>, path => <<>>}), "?name=%C3%B6rn" = - uri_string:recompose(#{query => "?name=örn", path => ""}), + uri_string:recompose(#{query => "name=örn", path => ""}), "?name=%C3%B6rn#n%C3%A4sa" = - uri_string:recompose(#{query => "?name=örn", + uri_string:recompose(#{query => "name=örn", fragment => "näsa", path => ""}). @@ -724,10 +727,10 @@ recompose_path(_Config) -> fragment => <<"näsa"/utf8>>}), <<"/d%C3%A4r?name=%C3%B6rn">> = uri_string:recompose(#{path => <<"/där"/utf8>>, - query => <<"?name=örn"/utf8>>}), + query => <<"name=örn"/utf8>>}), <<"/d%C3%A4r?name=%C3%B6rn#n%C3%A4sa">> = uri_string:recompose(#{path => <<"/där"/utf8>>, - query => <<"?name=örn"/utf8>>, + query => <<"name=örn"/utf8>>, fragment => <<"näsa"/utf8>>}), @@ -738,10 +741,10 @@ recompose_path(_Config) -> fragment => "näsa"}), "/d%C3%A4r?name=%C3%B6rn" = uri_string:recompose(#{path => "/där", - query => "?name=örn"}), + query => "name=örn"}), "/d%C3%A4r?name=%C3%B6rn#n%C3%A4sa" = uri_string:recompose(#{path => "/där", - query => "?name=örn", + query => "name=örn", fragment => "näsa"}). |