You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following monkey patch fixes the problem for single level hashed parameters:
module OAuth
module Helper
def normalize(params)
params.sort.map do |k, values|
if values.is_a?(Array)
# multiple values were provided for a single key
values.sort.collect do |v|
[escape(k),escape(v)] * "="
end
elsif values.is_a?(Hash)
key = k
values.sort.collect do |k, v|
[escape("#{key}[#{k}]"),escape(v)] * "="
end
else
[escape(k),escape(values)] * "="
end
end * "&"
end
end
end
The text was updated successfully, but these errors were encountered:
moduleOAuthmoduleHelper# see https://github.com/pelle/oauth/issues#issue/8defnormalize_hash_param(param,values)values.sort.collectdo |key,value|
ifvalue.is_a?(Hash)normalize_hash_param("#{param}[#{key}]",value)else[escape("#{param}[#{key}]"),escape(value)] * "="endendenddefnormalize(params)params.sort.mapdo |k,values|
ifvalues.is_a?(Array)# multiple values were provided for a single keyvalues.sort.collectdo |v|
[escape(k),escape(v)] * "="endelsifvalues.is_a?(Hash)normalize_hash_param(k,values)else[escape(k),escape(values)] * "="endend * "&"endendend
method OAuth::Helper::normalize doesn't correctly handle nested paramters.
Nesting parameters causes problems.
For example the following request has nested device[address], device[name], and device[app_user_id] query parameters.
This produces the following signature string which has incorrectly handled and sorted the device parameters:
The signature string for this set of parameters should be :
The following monkey patch fixes the problem for single level hashed parameters:
The text was updated successfully, but these errors were encountered: