actionpack 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +7 -0
- data/Rakefile +1 -1
- data/lib/action_controller/response.rb +2 -2
- data/lib/action_controller/routing/recognition_optimisation.rb +8 -4
- data/lib/action_controller/routing/route_set.rb +3 -2
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/helpers/form_options_helper.rb +1 -0
- data/lib/action_view/helpers/form_tag_helper.rb +7 -10
- data/test/controller/routing_test.rb +29 -0
- data/test/template/form_options_helper_test.rb +9 -3
- data/test/template/form_tag_helper_test.rb +2 -2
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
*2.1.2 (October 23rd, 2008)*
|
2
|
+
|
3
|
+
* Sanitize the URLs passed to redirect_to to prevent a potential response splitting attack [koz]
|
4
|
+
|
5
|
+
* Fixed FormTagHelper#submit_tag with :disable_with option wouldn't submit the button's value when was clicked #633 [Jose Fernandez]
|
6
|
+
|
7
|
+
|
1
8
|
*2.1.1 (September 4th, 2008)*
|
2
9
|
|
3
10
|
* All 2xx requests are considered successful [Josh Peek]
|
data/Rakefile
CHANGED
@@ -80,7 +80,7 @@ spec = Gem::Specification.new do |s|
|
|
80
80
|
s.has_rdoc = true
|
81
81
|
s.requirements << 'none'
|
82
82
|
|
83
|
-
s.add_dependency('activesupport', '= 2.1.
|
83
|
+
s.add_dependency('activesupport', '= 2.1.2' + PKG_BUILD)
|
84
84
|
|
85
85
|
s.require_path = 'lib'
|
86
86
|
s.autorequire = 'action_controller'
|
@@ -30,9 +30,9 @@ module ActionController
|
|
30
30
|
|
31
31
|
def redirect(to_url, response_status)
|
32
32
|
self.headers["Status"] = response_status
|
33
|
-
self.headers["Location"] = to_url
|
33
|
+
self.headers["Location"] = to_url.gsub(/[\r\n]/, '')
|
34
34
|
|
35
|
-
self.body = "<html><body>You are being <a href=\"#{to_url}\">redirected</a>.</body></html>"
|
35
|
+
self.body = "<html><body>You are being <a href=\"#{CGI.escapeHTML(to_url)}\">redirected</a>.</body></html>"
|
36
36
|
end
|
37
37
|
|
38
38
|
def prepare!
|
@@ -68,12 +68,16 @@ module ActionController
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
71
|
+
def clear_recognize_optimized!
|
72
|
+
instance_eval %{
|
73
|
+
def recognize_optimized(path, env)
|
74
|
+
write_recognize_optimized!
|
75
|
+
recognize_optimized(path, env)
|
76
|
+
end
|
77
|
+
}, __FILE__, __LINE__
|
74
78
|
end
|
75
79
|
|
76
|
-
def write_recognize_optimized
|
80
|
+
def write_recognize_optimized!
|
77
81
|
tree = segment_tree(routes)
|
78
82
|
body = generate_code(tree)
|
79
83
|
instance_eval %{
|
@@ -194,6 +194,7 @@ module ActionController
|
|
194
194
|
def initialize
|
195
195
|
self.routes = []
|
196
196
|
self.named_routes = NamedRouteCollection.new
|
197
|
+
clear_recognize_optimized!
|
197
198
|
end
|
198
199
|
|
199
200
|
# Subclasses and plugins may override this method to specify a different
|
@@ -213,9 +214,9 @@ module ActionController
|
|
213
214
|
named_routes.clear
|
214
215
|
@combined_regexp = nil
|
215
216
|
@routes_by_controller = nil
|
216
|
-
# This will force routing/
|
217
|
+
# This will force routing/recognition_optimisation.rb
|
217
218
|
# to refresh optimisations.
|
218
|
-
|
219
|
+
clear_recognize_optimized!
|
219
220
|
end
|
220
221
|
|
221
222
|
def install_helpers(destinations = [ActionController::Base, ActionView::Base], regenerate_code = false)
|
data/lib/action_pack/version.rb
CHANGED
@@ -400,6 +400,7 @@ module ActionView
|
|
400
400
|
end
|
401
401
|
|
402
402
|
def to_country_select_tag(priority_countries, options, html_options)
|
403
|
+
ActiveSupport::Deprecation.warn("country_select will be removed from 2.2.0. http://www.rubyonrails.org/deprecation/list-of-countries has more information.", caller)
|
403
404
|
html_options = html_options.stringify_keys
|
404
405
|
add_default_name_and_id(html_options)
|
405
406
|
value = value(object)
|
@@ -116,7 +116,7 @@ module ActionView
|
|
116
116
|
|
117
117
|
# Creates a label field
|
118
118
|
#
|
119
|
-
# ==== Options
|
119
|
+
# ==== Options
|
120
120
|
# * Creates standard HTML attributes for the tag.
|
121
121
|
#
|
122
122
|
# ==== Examples
|
@@ -351,19 +351,16 @@ module ActionView
|
|
351
351
|
disable_with = "this.value='#{disable_with}'"
|
352
352
|
disable_with << ";#{options.delete('onclick')}" if options['onclick']
|
353
353
|
|
354
|
-
options["onclick"]
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
"if (result == false) { this.value = this.getAttribute('originalValue'); this.disabled = false }",
|
360
|
-
"return result;",
|
361
|
-
].join(";")
|
354
|
+
options["onclick"] = "if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }"
|
355
|
+
options["onclick"] << "else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }"
|
356
|
+
options["onclick"] << "this.setAttribute('originalValue', this.value);this.disabled = true;#{disable_with};"
|
357
|
+
options["onclick"] << "result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());"
|
358
|
+
options["onclick"] << "if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;"
|
362
359
|
end
|
363
360
|
|
364
361
|
if confirm = options.delete("confirm")
|
365
362
|
options["onclick"] ||= ''
|
366
|
-
options["onclick"]
|
363
|
+
options["onclick"] << "return #{confirm_javascript_function(confirm)};"
|
367
364
|
end
|
368
365
|
|
369
366
|
tag :input, { "type" => "submit", "name" => "commit", "value" => value }.update(options.stringify_keys)
|
@@ -671,6 +671,35 @@ class LegacyRouteSetTests < Test::Unit::TestCase
|
|
671
671
|
x.send(:foo_with_requirement_url, "I am Against the requirements")
|
672
672
|
end
|
673
673
|
end
|
674
|
+
|
675
|
+
def test_routes_changed_correctly_after_clear
|
676
|
+
ActionController::Base.optimise_named_routes = true
|
677
|
+
rs = ::ActionController::Routing::RouteSet.new
|
678
|
+
rs.draw do |r|
|
679
|
+
r.connect 'ca', :controller => 'ca', :action => "aa"
|
680
|
+
r.connect 'cb', :controller => 'cb', :action => "ab"
|
681
|
+
r.connect 'cc', :controller => 'cc', :action => "ac"
|
682
|
+
r.connect ':controller/:action/:id'
|
683
|
+
r.connect ':controller/:action/:id.:format'
|
684
|
+
end
|
685
|
+
|
686
|
+
hash = rs.recognize_path "/cc"
|
687
|
+
|
688
|
+
assert_not_nil hash
|
689
|
+
assert_equal %w(cc ac), [hash[:controller], hash[:action]]
|
690
|
+
|
691
|
+
rs.draw do |r|
|
692
|
+
r.connect 'cb', :controller => 'cb', :action => "ab"
|
693
|
+
r.connect 'cc', :controller => 'cc', :action => "ac"
|
694
|
+
r.connect ':controller/:action/:id'
|
695
|
+
r.connect ':controller/:action/:id.:format'
|
696
|
+
end
|
697
|
+
|
698
|
+
hash = rs.recognize_path "/cc"
|
699
|
+
|
700
|
+
assert_not_nil hash
|
701
|
+
assert_equal %w(cc ac), [hash[:controller], hash[:action]]
|
702
|
+
end
|
674
703
|
end
|
675
704
|
|
676
705
|
class SegmentTest < Test::Unit::TestCase
|
@@ -656,7 +656,9 @@ uses_mocha "FormOptionsHelperTest" do
|
|
656
656
|
<option value="Zambia">Zambia</option>
|
657
657
|
<option value="Zimbabwe">Zimbabwe</option></select>
|
658
658
|
COUNTRIES
|
659
|
-
|
659
|
+
assert_deprecated 'list-of-countries' do
|
660
|
+
assert_dom_equal(expected_select[0..-2], country_select("post", "origin"))
|
661
|
+
end
|
660
662
|
end
|
661
663
|
|
662
664
|
def test_country_select_with_priority_countries
|
@@ -911,7 +913,9 @@ uses_mocha "FormOptionsHelperTest" do
|
|
911
913
|
<option value="Zambia">Zambia</option>
|
912
914
|
<option value="Zimbabwe">Zimbabwe</option></select>
|
913
915
|
COUNTRIES
|
914
|
-
|
916
|
+
assert_deprecated 'list-of-countries' do
|
917
|
+
assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"]))
|
918
|
+
end
|
915
919
|
end
|
916
920
|
|
917
921
|
def test_country_select_with_selected_priority_country
|
@@ -1166,7 +1170,9 @@ uses_mocha "FormOptionsHelperTest" do
|
|
1166
1170
|
<option value="Zambia">Zambia</option>
|
1167
1171
|
<option value="Zimbabwe">Zimbabwe</option></select>
|
1168
1172
|
COUNTRIES
|
1169
|
-
|
1173
|
+
assert_deprecated 'list-of-countries' do
|
1174
|
+
assert_dom_equal(expected_select[0..-2], country_select("post", "origin", ["New Zealand", "Nicaragua"]))
|
1175
|
+
end
|
1170
1176
|
end
|
1171
1177
|
|
1172
1178
|
def test_time_zone_select
|
@@ -223,14 +223,14 @@ class FormTagHelperTest < ActionView::TestCase
|
|
223
223
|
|
224
224
|
def test_submit_tag
|
225
225
|
assert_dom_equal(
|
226
|
-
%(<input name='commit' type='submit' value='Save' onclick="this.setAttribute('originalValue', this.value);this.disabled=true;this.value='Saving...';alert('hello!');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');
|
226
|
+
%(<input name='commit' type='submit' value='Save' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';alert('hello!');result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />),
|
227
227
|
submit_tag("Save", :disable_with => "Saving...", :onclick => "alert('hello!')")
|
228
228
|
)
|
229
229
|
end
|
230
230
|
|
231
231
|
def test_submit_tag_with_no_onclick_options
|
232
232
|
assert_dom_equal(
|
233
|
-
%(<input name='commit' type='submit' value='Save' onclick="this.setAttribute('originalValue', this.value);this.disabled=true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');
|
233
|
+
%(<input name='commit' type='submit' value='Save' onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = this.cloneNode(false);hiddenCommit.setAttribute('type', 'hidden');this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Saving...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />),
|
234
234
|
submit_tag("Save", :disable_with => "Saving...")
|
235
235
|
)
|
236
236
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ autorequire: action_controller
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-23 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 2.1.
|
23
|
+
version: 2.1.2
|
24
24
|
version:
|
25
25
|
description: Eases web-request routing, handling, and response as a half-way front, half-way page controller. Implemented with specific emphasis on enabling easy unit/integration testing that doesn't require a browser.
|
26
26
|
email: david@loudthinking.com
|
@@ -476,7 +476,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
476
476
|
requirements:
|
477
477
|
- none
|
478
478
|
rubyforge_project: actionpack
|
479
|
-
rubygems_version: 1.
|
479
|
+
rubygems_version: 1.3.0
|
480
480
|
signing_key:
|
481
481
|
specification_version: 2
|
482
482
|
summary: Web-flow and rendering framework putting the VC in MVC.
|