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

Changeset 8601

Show
Ignore:
Timestamp:
01/08/08 21:22:01 (6 months ago)
Author:
nzkoz
Message:

Don't append the forgery token to an ajax request if it's serializing a form, prevents duplicate tokens. References #10684 [macournoyer]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/2-0-stable/actionpack/lib/action_view/helpers/prototype_helper.rb

    r8323 r8601  
    10201020        end 
    10211021         
    1022         if protect_against_forgery? 
     1022        if protect_against_forgery? && !options[:form] 
    10231023          if js_options['parameters'] 
    10241024            js_options['parameters'] << " + '&" 
  • branches/2-0-stable/actionpack/test/controller/request_forgery_protection_test.rb

    r7719 r8601  
    2323  end 
    2424   
     25  def remote_form 
     26    render :inline => "<% form_remote_tag(:url => '/') {} %>" 
     27  end 
     28 
    2529  def unsafe 
    2630    render :text => 'pwn' 
     
    7680  end 
    7781 
     82  def test_should_render_remote_form_with_only_one_token_parameter 
     83    get :remote_form 
     84    assert_equal 1, @response.body.scan(@token).size 
     85  end 
     86 
    7887  def test_should_allow_get 
    7988    get :index