public
Description: Hampton Catlins and Nex3's make_resourceful plugin
Homepage: http://groups.google.com/group/make_resourceful
Clone URL: git://github.com/jcfischer/make_resourceful.git
Search Repo:
Added HTML escaping for _flash parameters values.
nbibler (author)
Sat Apr 12 11:12:59 -0700 2008
commit  26c3e0195e53b1c39bd3f26e7af6ec07c70e487c
tree    e9c08d70c96b9b057dd29c545c8690a97d71a9ed
parent  a34bdc3b25092da3cbf90f70e6f5ce90f6b4af3a
...
4
5
6
 
 
7
8
9
...
17
18
19
20
 
 
 
21
22
23
...
4
5
6
7
8
9
10
11
...
19
20
21
 
22
23
24
25
26
27
0
@@ -4,6 +4,8 @@ module Resourceful
0
       # Sets the default flash message.
0
       # This message can be overridden by passing in
0
       # an HTTP parameter of the form "_flash[type]" via POST or GET.
0
+ # _flash HTTP parameter values will be HTML escaped prior to
0
+ # being used.
0
       #
0
       # You can use this to easily have multiple forms
0
       # post to the same create/edit/destroy actions
0
@@ -17,7 +19,9 @@ module Resourceful
0
       # TODO: Move this out of here
0
       #++
0
       def set_default_flash(type, message)
0
- flash[type] ||= (params[:_flash] && params[:_flash][type]) || message
0
+ flash[type] ||= (params[:_flash] && params[:_flash][type]) ?
0
+ ERB::Util.h(params[:_flash][type]) :
0
+ message
0
       end
0
 
0
       # Sets the default redirect
...
14
15
16
 
 
 
 
 
 
 
17
18
19
...
14
15
16
17
18
19
20
21
22
23
24
25
26
0
@@ -14,6 +14,13 @@ describe 'Resourceful::Default::Responses', " with a _flash parameter for :error
0
     @controller.set_default_flash(:error, "Aw there's no error!")
0
     @flash[:error].should == 'Oh no, an error!'
0
   end
0
+
0
+ it "should set the flash for :error to the parameter's cleansed value when set_default_flash is called on :error" do
0
+ evil_script = "<script language=\"javascript\">alert('no good');</script>"
0
+ @params[:_flash][:error] = evil_script
0
+ @controller.set_default_flash(:error, "Aw there's no error!")
0
+ @flash[:error].should == ERB::Util.h(evil_script)
0
+ end
0
 
0
   it "should set the flash for :message to the default value when set_default_flash is called on :message" do
0
     @controller.set_default_flash(:message, "All jim dandy!")

Comments

    No one has commented yet.