elsif current_user
set_locale
respond_to do |format|
- format.html { redirect_to :controller => "errors", :action => "forbidden" }
+ format.html { redirect_to :controller => "/errors", :action => "forbidden" }
format.any { report_error t("application.permission_denied"), :forbidden }
end
elsif request.get?
# clean any referer parameter
def safe_referer(referer)
- referer = URI.parse(referer)
+ begin
+ referer = URI.parse(referer)
+
+ if referer.scheme == "http" || referer.scheme == "https"
+ referer.scheme = nil
+ referer.host = nil
+ referer.port = nil
+ elsif referer.scheme || referer.host || referer.port
+ referer = nil
+ end
- if referer.scheme == "http" || referer.scheme == "https"
- referer.scheme = nil
- referer.host = nil
- referer.port = nil
- elsif referer.scheme || referer.host || referer.port
+ referer = nil if referer&.path&.first != "/"
+ rescue URI::InvalidURIError
referer = nil
end
- referer = nil if referer&.path&.first != "/"
-
- referer.to_s
+ referer&.to_s
end
def scope_enabled?(scope)