1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #31815 from composerinteralia/make-request-id

Allow @ in X-Request-Id header
This commit is contained in:
George Claghorn 2018-01-29 20:45:02 -05:00 committed by GitHub
commit 8ef0751b12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -30,7 +30,7 @@ module ActionDispatch
private
def make_request_id(request_id)
if request_id.presence
request_id.gsub(/[^\w\-]/, "".freeze).first(255)
request_id.gsub(/[^\w\-@]/, "".freeze).first(255)
else
internal_request_id
end

View file

@ -11,6 +11,11 @@ class RequestIdTest < ActiveSupport::TestCase
assert_equal "X-Hacked-HeaderStuff", stub_request("HTTP_X_REQUEST_ID" => "; X-Hacked-Header: Stuff").request_id
end
test "accept Apache mod_unique_id format" do
mod_unique_id = "abcxyz@ABCXYZ-0123456789"
assert_equal mod_unique_id, stub_request("HTTP_X_REQUEST_ID" => mod_unique_id).request_id
end
test "ensure that 255 char limit on the request id is being enforced" do
assert_equal "X" * 255, stub_request("HTTP_X_REQUEST_ID" => "X" * 500).request_id
end