-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prevent underscores from clobbering hyphen headers * Special case encoding headers to prevent app confusion * Handle _ as , in jruby as well * Silence RuboCop offense --------- Co-authored-by: Patrik Ragnarsson <[email protected]>
- Loading branch information
1 parent
5fc43d7
commit cac3fd1
Showing
5 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "helper" | ||
|
||
require "puma/request" | ||
|
||
class TestNormalize < Minitest::Test | ||
parallelize_me! | ||
|
||
include Puma::Request | ||
|
||
def test_comma_headers | ||
env = { | ||
"HTTP_X_FORWARDED_FOR" => "1.1.1.1", | ||
"HTTP_X_FORWARDED,FOR" => "2.2.2.2", | ||
} | ||
|
||
req_env_post_parse env | ||
|
||
expected = { | ||
"HTTP_X_FORWARDED_FOR" => "1.1.1.1", | ||
} | ||
|
||
assert_equal expected, env | ||
|
||
# Test that the iteration order doesn't matter | ||
|
||
env = { | ||
"HTTP_X_FORWARDED,FOR" => "2.2.2.2", | ||
"HTTP_X_FORWARDED_FOR" => "1.1.1.1", | ||
} | ||
|
||
req_env_post_parse env | ||
|
||
expected = { | ||
"HTTP_X_FORWARDED_FOR" => "1.1.1.1", | ||
} | ||
|
||
assert_equal expected, env | ||
end | ||
|
||
def test_unmaskable_headers | ||
env = { | ||
"HTTP_CONTENT,LENGTH" => "100000", | ||
"HTTP_TRANSFER,ENCODING" => "chunky" | ||
} | ||
|
||
req_env_post_parse env | ||
|
||
expected = { | ||
"HTTP_CONTENT,LENGTH" => "100000", | ||
"HTTP_TRANSFER,ENCODING" => "chunky" | ||
} | ||
|
||
assert_equal expected, env | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters