File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -94,11 +94,26 @@ def sign_header(header)
9494 private
9595
9696 def parse_uri ( uri )
97- parsed_uri = URI . parse ( uri )
98-
99- return parsed_uri . request_uri if parsed_uri . respond_to? ( :request_uri )
97+ uri_without_host = uri . gsub ( URI_WITHOUT_HOST_REGEXP , '' )
98+ return '/' if uri_without_host . empty?
99+ escape_params ( uri_without_host )
100+ end
100101
101- uri . empty? ? '/' : uri
102+ # Different version of request parsers escape/unescape the param values
103+ # This will force param values to escaped
104+ def escape_params ( uri )
105+ unescaped_uri = CGI . unescape ( uri )
106+ uri_array = unescaped_uri . split ( '?' )
107+ return uri unless uri_array . length > 1
108+ params = uri_array [ 1 ] . split ( '&' )
109+ encoded_params = ""
110+ params . each do |param |
111+ next unless param . include? ( '=' )
112+ encoded_params += '&' if encoded_params . length . positive?
113+ split_param = param . split ( '=' )
114+ encoded_params += split_param [ 0 ] + '=' + CGI . escape ( split_param [ 1 ] )
115+ end
116+ uri_array [ 0 ] + '?' + encoded_params
102117 end
103118 end
104119end
You can’t perform that action at this time.
0 commit comments