Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forces request query param values to be escaped #162

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

DaKaZ
Copy link

@DaKaZ DaKaZ commented Dec 14, 2017

This PR fixes issue #123 where query strings are handled differently based on combinations of different libraries.

parsed_uri = URI.parse(uri)

return parsed_uri.request_uri if parsed_uri.respond_to?(:request_uri)
uri_without_host = uri.gsub(URI_WITHOUT_HOST_REGEXP, '')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is URI_WITHOUT_HOST_REGEXP ?

uri.empty? ? '/' : uri
# Different version of request parsers escape/unescape the param values
# This will force param values to escaped
def escape_params(uri)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is untest and very difficult to understand.

udpates params parsing function and adds tests

Corrects error in merge

udpates specs
@DaKaZ
Copy link
Author

DaKaZ commented Dec 18, 2017

@fwininger I am sorry about that - I had a local helper which I did not include. Please see the new PR code attached which includes several new specs for testing. Note: I had to add Rails as a gemspec dependency since ActiveResource requires it. I am happy to make any changes you see fit, I am just trying to solve a issue affecting multiple people.

end

it 'does not change request url (by removing host)' do
expect(request.url).to eq(uri)
end
end

if RUBY_VERSION.to_f > 2.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest-client will throw an exception for an invalid URI in ruby versions 2.1 and below, I needed this so that all the CI tests would pass. I believe, in later versions the URI is properly escaped rather than throwing the exception but I did not verify in the rest-client code.

@DaKaZ
Copy link
Author

DaKaZ commented Jan 4, 2018

@fwininger any additional thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants