app/controllers/application_controller.rb
##
# Returns a local URL path component to redirect to after an action.
# Will be taken from referer query param or referer HTTP header, in that
# order, but only used if allowable non-blacklisted internal URL, otherwise
# root_path is used.
#
# `redirect_path` performs some basic checks to ensure the URL is internal
#  and will not cause redirect loops.
Returns a local URL path component to redirect to after an action.
Will be taken from referer query param or referer HTTP header, in that
order, but only used if allowable non-blacklisted internal URL, otherwise
root_path is used.

`redirect_path` performs some basic checks to ensure the URL is internal
and will not cause redirect loops.
Returns a local URL path component to redirect to after an action . Will be taken from referer query param or referer HTTP header in that order but only used if allowable non - blacklisted internal URL otherwise root_path is used . ` redirect_path ` performs some basic checks to ensure the URL is internal and will not cause redirect loops .
def sanitize_redirect_url
    referer = params[:referer].blank? ?  request.referer : params[:referer]
    if referer && (referer =~ %r|^https?://#{request.host}#{root_path}| ||
        referer =~ %r|^https?://#{request.host}:#{request.port}#{root_path}|)
      referer.sub!(%r|^https?://#{request.host}(:#{request.port})?|, '')
    elsif referer && referer =~ %r|^(\w+:)?//|
      Rails.logger.debug("#post_auth_redirect_url will NOT use third party url for post login redirect: #{referer}")
      referer = nil
    end
    if referer && referer_blacklist.any? {|blacklisted| referer.starts_with?(blacklisted)  }
      Rails.logger.debug("#post_auth_redirect_url will NOT use a blacklisted url for post login redirect: #{referer}")
      referer = nil
    elsif referer && referer[0,1] != '/'
      Rails.logger.debug("#post_auth_redirect_url will NOT use partial path for post login redirect: #{referer}")
      referer = nil
    end
    return referer || root_path
  end
def sanitize_redirect_url referer = params [ :referer ] . blank? ? request . referer : params [ :referer ] if referer && ( referer =~ %r| ^https?:// #{ request . host } #{ root_path } | || referer =~ %r| ^https?:// #{ request . host } : #{ request . port } #{ root_path } | ) referer . sub! ( %r| ^https?:// #{ request . host } (: #{ request . port } )? | , '' ) elsif referer && referer =~ %r| ^( \w +:)?// | Rails . logger . debug ( "#post_auth_redirect_url will NOT use third party url for post login redirect: #{referer}" ) referer = nil end if referer && referer_blacklist . any? { | blacklisted | referer . starts_with? ( blacklisted ) } Rails . logger . debug ( "#post_auth_redirect_url will NOT use a blacklisted url for post login redirect: #{referer}" ) referer = nil elsif referer && referer [ 0 , 1 ] != '/' Rails . logger . debug ( "#post_auth_redirect_url will NOT use partial path for post login redirect: #{referer}" ) referer = nil end return referer || root_path end
Returns a local URL path component to redirect to after an action.
Returns a local URL path component to redirect to after an action .
#self-referencing absolute url, make it relative