Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 9212

Show
Ignore:
Timestamp:
04/02/08 12:48:59 (3 months ago)
Author:
pratik
Message:

Ensure RJS redirect_to doesn't html-escapes string argument. Closes #8546

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r9177 r9212  
    11*SVN* 
     2 
     3* Ensure RJS redirect_to doesn't html-escapes string argument. Closes #8546 [josh, eventualbuddha, Pratik] 
    24 
    35* Support render :partial => collection of heterogeneous elements.  #11491 [Zach Dennis] 
  • trunk/actionpack/lib/action_view/helpers/prototype_helper.rb

    r9195 r9212  
    844844          #  page.redirect_to(:controller => 'account', :action => 'signup') 
    845845          def redirect_to(location) 
    846             assign 'window.location.href', @context.url_for(location) 
     846            url = location.is_a?(String) ? location : @context.url_for(location) 
     847            record "window.location.href = #{url.inspect}" 
    847848          end 
    848849           
  • trunk/actionpack/test/controller/redirect_test.rb

    r8633 r9212  
    6464    @hello = "world" 
    6565    redirect_to :action => "hello_world" 
     66  end 
     67 
     68  def redirect_to_url 
     69    redirect_to "http://www.rubyonrails.org/" 
     70  end 
     71 
     72  def redirect_to_url_with_unescaped_query_string 
     73    redirect_to "http://dev.rubyonrails.org/query?status=new" 
    6674  end 
    6775 
     
    194202  end 
    195203 
     204  def test_redirect_to_url 
     205    get :redirect_to_url 
     206    assert_response :redirect 
     207    assert_redirected_to "http://www.rubyonrails.org/" 
     208  end 
     209 
     210  def test_redirect_to_url_with_unescaped_query_string 
     211    get :redirect_to_url_with_unescaped_query_string 
     212    assert_response :redirect 
     213    assert_redirected_to "http://dev.rubyonrails.org/query?status=new" 
     214  end 
     215 
    196216  def test_redirect_to_back 
    197217    @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from" 
  • trunk/actionpack/test/template/prototype_helper_test.rb

    r8564 r9212  
    359359    assert_equal 'window.location.href = "http://www.example.com/welcome";', 
    360360      @generator.redirect_to(:action => 'welcome') 
     361    assert_equal 'window.location.href = "http://www.example.com/welcome?a=b&c=d";', 
     362      @generator.redirect_to("http://www.example.com/welcome?a=b&c=d") 
    361363  end 
    362364