From 6709e7a508e4b3e46df2022c92cde41c45615142 Mon Sep 17 00:00:00 2001 From: Kyle Boe Date: Mon, 9 Oct 2023 17:17:58 -0700 Subject: [PATCH] Fix partial_pathencode to properly handle asterisk (*) (#720) Ref: - https://github.com/edgurgel/httpoison/issues/471 - https://github.com/benoitc/hackney/issues/399 - https://github.com/benoitc/hackney/issues/277 - https://github.com/benoitc/hackney/issues/272 --- src/hackney_url.erl | 2 +- test/hackney_url_tests.erl | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hackney_url.erl b/src/hackney_url.erl index bd9c063c..5d93d460 100644 --- a/src/hackney_url.erl +++ b/src/hackney_url.erl @@ -461,7 +461,7 @@ partial_pathencode(<> = Bin, Acc) -> if C >= $0, C =< $9 -> partial_pathencode(Rest, <>); C >= $A, C =< $Z -> partial_pathencode(Rest, <>); C >= $a, C =< $z -> partial_pathencode(Rest, <>); - C =:= $;; C =:= $=; C =:= $,; C =:= $:; C =:= $@; C =:= $(; C =:= $) -> + C =:= $;; C =:= $=; C =:= $,; C =:= $:; C =:= $*; C =:= $@; C =:= $(; C =:= $) -> partial_pathencode(Rest, <>); C =:= $.; C =:= $-; C =:= $+; C =:= $~; C =:= $_ -> partial_pathencode(Rest, <>); diff --git a/test/hackney_url_tests.erl b/test/hackney_url_tests.erl index b16a3046..a0945140 100644 --- a/test/hackney_url_tests.erl +++ b/test/hackney_url_tests.erl @@ -382,7 +382,8 @@ pathencode_test_() -> {<<"/id/name:107/name2;p=1,3">>, <<"/id/name:107/name2;p=1,3">>}, {<<"/@foobar">>, <<"/@foobar">>}, {<<"/500x720/filters:quality(75):format(jpg)/spree/product/s/p/spree2018september12picslgzh0650.jpg">>, - <<"/500x720/filters:quality(75):format(jpg)/spree/product/s/p/spree2018september12picslgzh0650.jpg">>} + <<"/500x720/filters:quality(75):format(jpg)/spree/product/s/p/spree2018september12picslgzh0650.jpg">>}, + {<<"/1/indexes/*/queries">>, <<"/1/indexes/*/queries">>} ], [{V, fun() -> R = hackney_url:pathencode(V) end} || {V, R} <- Tests].