-
Notifications
You must be signed in to change notification settings - Fork 558
Added CGI::Util.escapeURIComponent
and unescapeURIComponent
#8913
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
base: master
Are you sure you want to change the base?
Added CGI::Util.escapeURIComponent
and unescapeURIComponent
#8913
Conversation
I tried running |
c786e49
to
4cf161f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems reasonable, thank you!
There's a test failure due to a missing error assertion in your new test, which you can see locally by running:
./bazel test \
//test:test_LSPTests/testdata/rbi/cgi \
//test:test_PosTests/testdata/rbi/cgi \
--config=dbg --test_output=errors
require 'cgi' | ||
|
||
T.assert_type!(CGI.escapeURIComponent("'Stop!' said Fred"), String) | ||
T.assert_type!(CGI.unescapeURIComponent("%27Stop%21%27+said%20Fred"), String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test failure is because you're missing an error annotation for this line.
https://buildkite.com/sorbet/sorbet/builds/36003#0196fd92-37e9-466c-8874-ce6f2a166a59/143-446
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the tip on how to run Bazel for CGI only. I have a green build for testdata/../cgi on my end.
# ``` | ||
sig do | ||
params( | ||
string: ::T.untyped |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these really untyped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No they aren't, but if you look at the whole file, you'll see that everything else in this file is untyped. I wanted to make the smallest possible change that would be acceptable. I have another PR waiting in the wings with stronger type assertions, where inputs are String and return values are String as well.
I can type these two methods now, and the next PR will type the remaining methods.
Happy to do whatever will get this upstreamed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with T.untyped
for now, thank you for making incremental changes!
In Nov 2021, CGI gained `escapeURIComponent` and `unescapeURIComponent` which were missing from the signatures.
4cf161f
to
5490d61
Compare
We have a policy of testing changes to Sorbet against Stripe's codebase before Stripe employees can see the build results here: → https://go/builds/bui_SMlfTnL0D8ISUq |
I needed to make a small change to Stripe's codebase to land this change, and once that's present I'll approve and merge this PR. Thanks again! |
In Nov 2021, CGI gained
escapeURIComponent
andunescapeURIComponent
which were missing from the signatures.Motivation
This Sorbet playground example fails because the
CGI.escapeURIComponent
signature does not exist at all: https://sorbet.run/#%23%20typed%3A%20true%0Aextend%20T%3A%3ASig%0A%0Arequire%20%22cgi%22%0ACGI.escapeURIComponent%28%22tada%26%22%29Test plan
A new
cgi.rb
file was added to assert a minimum of type checking for only these two methods.Most of
CGI::Util
is defined as taking untyped values and returning untyped values. A separate PR will be made to address that.