Skip to content

Commit

Permalink
fix(hackney_url): pass "@" unescaped
Browse files Browse the repository at this point in the history
In Chromium's [kPathCharLookup][1] table, the commercial at symbol is
given the flag to pass through without being escaped. This is due to
some web services using this character as a delimiter without first unescaping.

[1]: https://src.chromium.org/viewvc/chrome/trunk/src/url/url_canon_path.cc?pathrev=265120#l60
  • Loading branch information
terinjokes committed Feb 10, 2016
1 parent 4517249 commit 725c008
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/http/hackney_url.erl
Expand Up @@ -368,7 +368,7 @@ partial_pathencode(<<C, Rest/binary>> = Bin, Acc) ->
if C >= $0, C =< $9 -> partial_pathencode(Rest, <<Acc/binary, C>>);
C >= $A, C =< $Z -> partial_pathencode(Rest, <<Acc/binary, C>>);
C >= $a, C =< $z -> partial_pathencode(Rest, <<Acc/binary, C>>);
C =:= $;; C =:= $=; C =:= $,; C =:= $: ->
C =:= $;; C =:= $=; C =:= $,; C =:= $:; C =:= $@ ->
partial_pathencode(Rest, <<Acc/binary, C>>);
C =:= $.; C =:= $-; C =:= $+; C =:= $~; C =:= $_ ->
partial_pathencode(Rest, <<Acc/binary, C>>);
Expand Down
3 changes: 2 additions & 1 deletion test/hackney_url_tests.erl
Expand Up @@ -259,7 +259,8 @@ pathencode_test_() ->
{<<"/path1/path2%2fa">>, <<"/path1/path2%2fa">>},
{<<"/path1/path2%2fa%2fb">>, <<"/path1/path2%2fa%2fb">>},
{<<"/path1/path2%2test">>, <<"/path1/path2%252test">>},
{<<"/id/name:107/name2;p=1,3">>, <<"/id/name:107/name2;p=1,3">>}
{<<"/id/name:107/name2;p=1,3">>, <<"/id/name:107/name2;p=1,3">>},
{<<"/@foobar">>, <<"/@foobar">>}
],
[{V, fun() -> R = hackney_url:pathencode(V) end} || {V, R} <- Tests].

Expand Down

0 comments on commit 725c008

Please sign in to comment.