Browse Source

Fix URI template reserved expansion of %-encoded

Loïc Hoguin 3 years ago
parent
commit
79966f4d25
1 changed files with 4 additions and 0 deletions
  1. 4 0
      src/cow_uri_template.erl

+ 4 - 0
src/cow_uri_template.erl

@@ -310,6 +310,9 @@ urlencode_unreserved(<<C,R/bits>>, Acc) ->
 urlencode_unreserved(<<>>, Acc) ->
 urlencode_unreserved(<<>>, Acc) ->
 	Acc.
 	Acc.
 
 
+urlencode_reserved(<<$%,H,L,R/bits>>, Acc)
+		when ?IS_HEX(H), ?IS_HEX(L) ->
+	urlencode_reserved(R, <<Acc/binary,$%,H,L>>);
 urlencode_reserved(<<C,R/bits>>, Acc)
 urlencode_reserved(<<C,R/bits>>, Acc)
 		when ?IS_URI_UNRESERVED(C) or ?IS_URI_GEN_DELIMS(C) or ?IS_URI_SUB_DELIMS(C) ->
 		when ?IS_URI_UNRESERVED(C) or ?IS_URI_GEN_DELIMS(C) or ?IS_URI_SUB_DELIMS(C) ->
 	urlencode_reserved(R, <<Acc/binary,C>>);
 	urlencode_reserved(R, <<Acc/binary,C>>);
@@ -336,6 +339,7 @@ expand_uritemplate_test_() ->
 						end
 						end
 					])),
 					])),
 					fun() ->
 					fun() ->
+						io:format("expected: ~0p", [Expected]),
 						case Expected of
 						case Expected of
 							false ->
 							false ->
 								{'EXIT', _} = (catch expand(URITemplate, Vars));
 								{'EXIT', _} = (catch expand(URITemplate, Vars));