Skip to content
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

Fixes #36768: Prevent redirection to other hosts via HTTP referer header #9840

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def process_ajax_error(exception, action = nil)
end

def redirect_back_or_to(url)
redirect_back(fallback_location: url)
redirect_back(fallback_location: url, allow_other_host: false)
end

def saved_redirect_url_or(default)
Expand Down
2 changes: 1 addition & 1 deletion test/controllers/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class UsersControllerTest < ActionController::TestCase

context "when user is logged in" do
test "#login redirects to previous url" do
@previous_url = "/bookmarks"
@previous_url = "http://test.host/bookmarks"
get :login, session: set_session_user
request.env['HTTP_REFERER'] = @previous_url

Expand Down