Skip to content

Commit 69b6bc5

Browse files
authored
Merge pull request rails#54613 from ioquatix/rack-lint-compatibility
Make lint optional, so we can pass invalid host name.
2 parents 251517a + 0108ccf commit 69b6bc5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

actionpack/test/dispatch/host_authorization_test.rb

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class HostAuthorizationTest < ActionDispatch::IntegrationTest
443443
end
444444

445445
test "blocks requests with invalid hostnames" do
446-
@app = build_app(".example.com")
446+
@app = build_app(".example.com", lint: false)
447447

448448
get "/", env: {
449449
"HOST" => "attacker.com#x.example.com",
@@ -493,11 +493,17 @@ class HostAuthorizationTest < ActionDispatch::IntegrationTest
493493
end
494494

495495
private
496-
def build_app(hosts, exclude: nil, response_app: nil)
497-
Rack::Lint.new(
498-
ActionDispatch::HostAuthorization.new(
499-
Rack::Lint.new(App), hosts, exclude: exclude, response_app: response_app
500-
)
501-
)
496+
def build_app(hosts, exclude: nil, response_app: nil, lint: true, app: App)
497+
if lint
498+
app = Rack::Lint.new(app)
499+
end
500+
501+
app = ActionDispatch::HostAuthorization.new(app, hosts, exclude: exclude, response_app: response_app)
502+
503+
if lint
504+
Rack::Lint.new(app)
505+
end
506+
507+
app
502508
end
503509
end

0 commit comments

Comments
 (0)