-
Notifications
You must be signed in to change notification settings - Fork 120
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
Sanitize UTF8 characters from headers #1674
Conversation
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.
LGTM!
7c00e17
to
f58943f
Compare
spec/requests/headers_spec.rb
Outdated
@@ -24,4 +24,10 @@ | |||
|
|||
expect(response.code.to_i).to eq(404) | |||
end | |||
|
|||
it 'handles headers that are not ASCII encodable' do | |||
get root_path, headers: { 'Host' => '¿/?' } |
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 might be the wrong header to test because we delete the entire header?
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 changed up this spec so that it doesn't use the Host header. Mind taking another look?
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.
LGTM! Thanks for fixing
289d3de
to
759f522
Compare
**Why**: Rack encodes headers into 8 bit ASCII which results in encoding compadibility errors futher down the stack when the app tries to manipulate them. This commit encodes the headers and replaces incompatible characters with `?` characters so the headers do not cause the app to respond with 500s.
Why: Rack encodes headers into 8 bit ASCII which results in encoding
compatibility errors further down the stack when the app tries to
manipulate them. This commit encodes the headers and replaces
incompatible characters with
?
characters so the headers do not causethe app to respond with 500s.