diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 9e604e37a5..8803a1dd34 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Change url_for to escape the resulting URLs when called from a view. [Nicholas Seckar, eddiewould@paradise.net.nz] + * Added easy support for testing file uploads with fixture_file_upload #4105 [turnip@turnipspatch.com]. Example: # Looks in Test::Unit::TestCase.fixture_path + '/files/spongebob.png' diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index de6137659e..c4c8fca98e 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -15,7 +15,7 @@ module ActionView # http://example.com/controller/action part (makes it harder to parse httpd log files) def url_for(options = {}, *parameters_for_method_reference) options = { :only_path => true }.update(options.symbolize_keys) if options.kind_of? Hash - @controller.send(:url_for, options, *parameters_for_method_reference) + html_escape(@controller.send(:url_for, options, *parameters_for_method_reference)) end # Creates a link tag of the given +name+ using an URL created by the set of +options+. See the valid options in @@ -46,8 +46,8 @@ module ActionView else tag_options = nil end - url = html_escape(options.is_a?(String) ? options : url_for(options, *parameters_for_method_reference)) - "#{name||url}" + url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference) + "#{name || url}" end # Generates a form containing a sole button that submits to the @@ -104,11 +104,10 @@ module ActionView if confirm = html_options.delete("confirm") html_options["onclick"] = "return #{confirm_javascript_function(confirm)};" end - - url, name = options.is_a?(String) ? - [ options, name || options ] : - [ url_for(options), name || html_escape(url_for(options)) ] - + + url = options.is_a?(String) ? options : url_for(options) + name ||= url + html_options.merge!("type" => "submit", "value" => name) "