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

Remove deprecated URI.escape #993

Merged
merged 1 commit into from
Aug 28, 2020
Merged

Remove deprecated URI.escape #993

merged 1 commit into from
Aug 28, 2020

Conversation

waltjones
Copy link
Contributor

Description of the change

Removes the deprecated URI.escape, which has been deprecated for a long time, but the warnings are now more visible in Ruby 2.7.

The previous code had ended up performing several transforms in order to unencode square brackets while keeping everything else correctly encoded. Condensed, it was effectively like this:
URI.escape(CGI.unescape(URI.encode_www_form(params)))

This is all necessary because URI.encode_www_form percent encodes square brackets, but we want them unencoded.

This PR refactors and takes a simpler approach. As a side note, the debate about whether unencoded brackets should be allowed in URLs is not as relevant here since these are only used as debugging data in Rollbar payloads. They aren't being used to perform actual http requests.

The original URL may or may not have been percent encoded. The previous code didn't preserve the original state, and neither does this PR. The unencoded brackets are more readable, and is what everyone has been expecting and getting in their Rollbar dashboard, so we keep it that way.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Related issues

Fixes: #989
ch71576

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers mentioned in a comment
  • Changes have been reviewed by at least one other engineer
  • Issue from task tracker has a link to this pull request

#
# URI.encode_www_form follows the spec at https://url.spec.whatwg.org/#concept-urlencoded-serializer
# and percent encodes square brackets. Here we change them back.
query.gsub('%5B', '[').gsub('%5D', ']')

Choose a reason for hiding this comment

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

Simple but interesting stuff. I didn't know about gsub before.

@waltjones waltjones merged commit ff5863f into master Aug 28, 2020
@waltjones waltjones deleted the wj-remove-uri-escape branch June 27, 2023 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rollbar is using URI.escape that is already obsolete in ruby v2.7
2 participants