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

Apply CGI.escape to non-array non-form values #722

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

Conversation

krainboltgreene
Copy link

Problem

A string query param described in an rswag integration spec gets escaped in rspec tests and doesn't get escaped in rswag non-dry run.

Solution

Apply the same array and form escaping to everything else.

The changes I made are compatible with:

  • OAS2
  • OAS3
  • OAS3.1

Checklist

  • Added tests
  • Changelog updated
  • Added documentation to README.md
  • Added example of using the enhancement into test-app

Steps to Test or Reproduce

  1. Have a query param called x that is a string and contains a #, for example: ?filter[description]=Order for #231
  2. Run the test and inspect the params in the controller

@@ -174,7 +174,7 @@ def build_query_string_part(param, value, swagger_doc)
return "#{escaped_name}=" + value.to_a.flatten.map{|v| CGI.escape(v.to_s) }.join(separator)
end
else
return "#{name}=#{value}"
return "#{name}=#{CGI.escape(value)}"

Choose a reason for hiding this comment

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

CGI.escape(value.to_s)
The to_s was implicit before.

@BrianHawley
Copy link

#725 fixes the same bug but does the change I suggested instead. It should be used instead.

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