diff --git a/CHANGELOG.md b/CHANGELOG.md index 26b548c3..29a9444e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ calling `super` * Serialize the `last_request_at` entry as an Integer * Ensure registration controller block yields happen on failure in addition to success (by @dpehrson) - * Storing location only for valid url (by @parallel588) + * Only valid paths will be stored for redirections (by @parallel588) ### 3.2.4 diff --git a/lib/devise/controllers/store_location.rb b/lib/devise/controllers/store_location.rb index b9102ec1..ad36a4f0 100644 --- a/lib/devise/controllers/store_location.rb +++ b/lib/devise/controllers/store_location.rb @@ -33,7 +33,8 @@ module Devise # def store_location_for(resource_or_scope, location) session_key = stored_location_key_for(resource_or_scope) - if (uri = parse_uri(location)) + uri = parse_uri(location) + if uri session[session_key] = [uri.path.sub(/\A\/+/, '/'), uri.query].compact.join('?') end end