From 1a2063fe7e8646e46a88a98eba64f2294ee8147a Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 9 Jan 2017 16:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=90=E4=B8=AA=E9=A1=B5=E9=9D=A2=E8=B7=B3?= =?UTF-8?q?=E5=85=A5=E7=99=BB=E5=BD=95=EF=BC=8C=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E8=BF=94=E5=9B=9E=E5=BD=93=E5=89=8D=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 21653b3e4..33902ccc4 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -577,19 +577,19 @@ class ApplicationController < ActionController::Base end def redirect_back_or_default(default, options={}) - back_url = '' #params[:back_url].to_s + back_url = params[:back_url].to_s if back_url.present? begin uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) - back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(:User) + back_url = back_url.gsub(%r{\/users\/(\d+)},"/users/"+default.id.to_s) if default.is_a?(User) redirect_to(back_url) return end rescue URI::InvalidURIError logger.warn("Could not redirect to invalid URL #{back_url}") - # redirect to default + redirect to default end elsif options[:referer] redirect_to_referer_or default