From 3ba6ae95f0da7b69f6c16ad61df027234a20506a Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 18 Apr 2013 16:55:40 +0100 Subject: [PATCH] Duplicate options before mutating them --- actionpack/lib/action_dispatch/http/url.rb | 1 + actionpack/lib/action_dispatch/routing/route_set.rb | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/action_dispatch/http/url.rb b/actionpack/lib/action_dispatch/http/url.rb index e9d4cd6c34007..5caff769bba0a 100644 --- a/actionpack/lib/action_dispatch/http/url.rb +++ b/actionpack/lib/action_dispatch/http/url.rb @@ -28,6 +28,7 @@ def extract_subdomain(host, tld_length = @@tld_length) end def url_for(options = {}) + options = options.dup path = options.delete(:script_name).to_s.chomp("/") path << options.delete(:path).to_s diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index d48a83e6c6fc0..342b6ec23d109 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -170,9 +170,10 @@ def initialize(route, options) def call(t, args) if args.size == arg_size && !args.last.is_a?(Hash) && optimize_routes_generation?(t) - @options.merge!(t.url_options) if t.respond_to?(:url_options) - @options[:path] = optimized_helper(args) - ActionDispatch::Http::URL.url_for(@options) + options = @options.dup + options.merge!(t.url_options) if t.respond_to?(:url_options) + options[:path] = optimized_helper(args) + ActionDispatch::Http::URL.url_for(options) else super end