actionpack 1.13.4 → 1.13.5
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/assertions/response_assertions.rb +1 -0
- data/lib/action_controller/assertions/selector_assertions.rb +2 -0
- data/lib/action_controller/macros/in_place_editing.rb +1 -1
- data/lib/action_controller/routing.rb +15 -22
- data/lib/action_pack/version.rb +1 -1
- data/test/controller/action_pack_assertions_test.rb +13 -0
- data/test/controller/routing_test.rb +1 -1
- data/test/controller/url_rewriter_test.rb +54 -10
- data/test/template/javascript_helper_test.rb +4 -4
- data/test/template/prototype_helper_test.rb +11 -11
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
*1.13.5* (October 12th, 2007)
|
2
|
+
|
3
|
+
* Backport: allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan, Diego Algorta Casamayou]
|
4
|
+
|
5
|
+
* Fix in place editor's setter action with non-string fields. #7418 [Andreas]
|
6
|
+
|
7
|
+
|
1
8
|
*1.13.4* (October 4th, 2007)
|
2
9
|
|
3
10
|
* Only accept session ids from cookies, prevents session fixation attacks. [bradediger]
|
data/Rakefile
CHANGED
@@ -75,7 +75,7 @@ spec = Gem::Specification.new do |s|
|
|
75
75
|
s.has_rdoc = true
|
76
76
|
s.requirements << 'none'
|
77
77
|
|
78
|
-
s.add_dependency('activesupport', '= 1.4.
|
78
|
+
s.add_dependency('activesupport', '= 1.4.4' + PKG_BUILD)
|
79
79
|
|
80
80
|
s.require_path = 'lib'
|
81
81
|
s.autorequire = 'action_controller'
|
@@ -69,6 +69,7 @@ module ActionController
|
|
69
69
|
end
|
70
70
|
|
71
71
|
if value.respond_to?(:[]) && value['controller']
|
72
|
+
value['controller'] = value['controller'].to_s
|
72
73
|
if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
|
73
74
|
new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
|
74
75
|
value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path)
|
@@ -561,6 +561,8 @@ module ActionController
|
|
561
561
|
# RJS encodes double quotes and line breaks.
|
562
562
|
unescaped= rjs_string.gsub('\"', '"')
|
563
563
|
unescaped.gsub!('\n', "\n")
|
564
|
+
unescaped.gsub!('\076', '>')
|
565
|
+
unescaped.gsub!('\074', '<')
|
564
566
|
# RJS encodes non-ascii characters.
|
565
567
|
unescaped.gsub!(RJS_PATTERN_UNICODE_ESCAPED_CHAR) {|u| [$1.hex].pack('U*')}
|
566
568
|
unescaped
|
@@ -24,7 +24,7 @@ module ActionController
|
|
24
24
|
define_method("set_#{object}_#{attribute}") do
|
25
25
|
@item = object.to_s.camelize.constantize.find(params[:id])
|
26
26
|
@item.update_attribute(attribute, params[:value])
|
27
|
-
render :text => @item.send(attribute)
|
27
|
+
render :text => @item.send(attribute).to_s
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -451,26 +451,17 @@ module ActionController
|
|
451
451
|
# is given (as an array), only the keys indicated will be used to build
|
452
452
|
# the query string. The query string will correctly build array parameter
|
453
453
|
# values.
|
454
|
-
def build_query_string(hash, only_keys=nil)
|
454
|
+
def build_query_string(hash, only_keys = nil)
|
455
455
|
elements = []
|
456
|
-
|
457
|
-
only_keys ||= hash.keys
|
458
|
-
|
459
|
-
only_keys.each do |key|
|
460
|
-
value = hash[key] or next
|
461
|
-
key = CGI.escape key.to_s
|
462
|
-
if value.class == Array
|
463
|
-
key << '[]'
|
464
|
-
else
|
465
|
-
value = [ value ]
|
466
|
-
end
|
467
|
-
value.each { |val| elements << "#{key}=#{CGI.escape(val.to_param.to_s)}" }
|
468
|
-
end
|
469
456
|
|
470
|
-
|
471
|
-
|
457
|
+
(only_keys || hash.keys).each do |key|
|
458
|
+
if value = hash[key]
|
459
|
+
elements << value.to_query(key)
|
460
|
+
end
|
461
|
+
end
|
462
|
+
elements.empty? ? '' : "?#{elements.sort * '&'}"
|
472
463
|
end
|
473
|
-
|
464
|
+
|
474
465
|
# Write the real recognition implementation and then resend the message.
|
475
466
|
def recognize(path, environment={})
|
476
467
|
write_recognition
|
@@ -668,7 +659,7 @@ module ActionController
|
|
668
659
|
end
|
669
660
|
|
670
661
|
def extract_value
|
671
|
-
"#{local_name} = hash[:#{key}] #{"|| #{default.inspect}" if default}"
|
662
|
+
"#{local_name} = hash[:#{key}] && hash[:#{key}].to_param #{"|| #{default.inspect}" if default}"
|
672
663
|
end
|
673
664
|
def value_check
|
674
665
|
if default # Then we know it won't be nil
|
@@ -1230,10 +1221,9 @@ module ActionController
|
|
1230
1221
|
#
|
1231
1222
|
# great fun, eh?
|
1232
1223
|
|
1233
|
-
options_as_params = options
|
1234
|
-
|
1235
|
-
|
1236
|
-
end
|
1224
|
+
options_as_params = options.clone
|
1225
|
+
options_as_params[:action] ||= 'index' if options[:controller]
|
1226
|
+
options_as_params[:action] = options_as_params[:action].to_s if options_as_params[:action]
|
1237
1227
|
options_as_params
|
1238
1228
|
end
|
1239
1229
|
|
@@ -1264,6 +1254,9 @@ module ActionController
|
|
1264
1254
|
options = options_as_params(options)
|
1265
1255
|
expire_on = build_expiry(options, recall)
|
1266
1256
|
|
1257
|
+
if options[:controller]
|
1258
|
+
options[:controller] = options[:controller].to_s
|
1259
|
+
end
|
1267
1260
|
# if the controller has changed, make sure it changes relative to the
|
1268
1261
|
# current controller module, if any. In other words, if we're currently
|
1269
1262
|
# on admin/get, and the new controller is 'set', the new controller
|
data/lib/action_pack/version.rb
CHANGED
@@ -19,6 +19,8 @@ class ActionPackAssertionsController < ActionController::Base
|
|
19
19
|
|
20
20
|
def redirect_to_controller() redirect_to :controller => "elsewhere", :action => "flash_me"; end
|
21
21
|
|
22
|
+
def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere, :action => :flash_me; end
|
23
|
+
|
22
24
|
def redirect_to_path() redirect_to '/some/path' end
|
23
25
|
|
24
26
|
def redirect_to_named_route() redirect_to route_one_url end
|
@@ -555,6 +557,17 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
|
555
557
|
assert_redirected_to 'http://test.host/some/path'
|
556
558
|
end
|
557
559
|
|
560
|
+
def test_assert_redirection_with_symbol
|
561
|
+
process :redirect_to_controller_with_symbol
|
562
|
+
assert_nothing_raised {
|
563
|
+
assert_redirected_to :controller => "elsewhere", :action => "flash_me"
|
564
|
+
}
|
565
|
+
process :redirect_to_controller_with_symbol
|
566
|
+
assert_nothing_raised {
|
567
|
+
assert_redirected_to :controller => :elsewhere, :action => :flash_me
|
568
|
+
}
|
569
|
+
end
|
570
|
+
|
558
571
|
def test_redirected_to_with_nested_controller
|
559
572
|
@controller = Admin::InnerModuleController.new
|
560
573
|
get :redirect_to_absolute_controller
|
@@ -946,7 +946,7 @@ class RouteTest < Test::Unit::TestCase
|
|
946
946
|
end
|
947
947
|
|
948
948
|
def test_expand_array_build_query_string
|
949
|
-
assert_equal '?x
|
949
|
+
assert_equal '?x%5B%5D=1&x%5B%5D=2', order_query_string(@route.build_query_string(:x => [1, 2]))
|
950
950
|
end
|
951
951
|
|
952
952
|
def test_escape_spaces_build_query_string_selected_keys
|
@@ -23,15 +23,6 @@ class UrlRewriterTests < Test::Unit::TestCase
|
|
23
23
|
@rewriter.rewrite(:controller => 'c', :action => 'a', :id => 'i', :anchor => 'anchor')
|
24
24
|
)
|
25
25
|
end
|
26
|
-
|
27
|
-
private
|
28
|
-
def split_query_string(str)
|
29
|
-
[str[0].chr] + str[1..-1].split(/&/).sort
|
30
|
-
end
|
31
|
-
|
32
|
-
def assert_query_equal(q1, q2)
|
33
|
-
assert_equal(split_query_string(q1), split_query_string(q2))
|
34
|
-
end
|
35
26
|
end
|
36
27
|
|
37
28
|
class UrlWriterTests < Test::Unit::TestCase
|
@@ -123,5 +114,58 @@ class UrlWriterTests < Test::Unit::TestCase
|
|
123
114
|
ensure
|
124
115
|
ActionController::Routing::Routes.load!
|
125
116
|
end
|
126
|
-
|
117
|
+
|
118
|
+
def test_one_parameter
|
119
|
+
assert_equal('/c/a?param=val',
|
120
|
+
W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :param => 'val')
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_two_parameters
|
125
|
+
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :p1 => 'X1', :p2 => 'Y2')
|
126
|
+
params = extract_params(url)
|
127
|
+
assert_equal params[0], { :p1 => 'X1' }.to_query
|
128
|
+
assert_equal params[1], { :p2 => 'Y2' }.to_query
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_hash_parameter
|
132
|
+
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:name => 'Bob', :category => 'prof'})
|
133
|
+
params = extract_params(url)
|
134
|
+
assert_equal params[0], { 'query[category]' => 'prof' }.to_query
|
135
|
+
assert_equal params[1], { 'query[name]' => 'Bob' }.to_query
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_array_parameter
|
139
|
+
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => ['Bob', 'prof'])
|
140
|
+
params = extract_params(url)
|
141
|
+
assert_equal params[0], { 'query[]' => 'Bob' }.to_query
|
142
|
+
assert_equal params[1], { 'query[]' => 'prof' }.to_query
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_hash_recursive_parameters
|
146
|
+
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :query => {:person => {:name => 'Bob', :position => 'prof'}, :hobby => 'piercing'})
|
147
|
+
params = extract_params(url)
|
148
|
+
assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query
|
149
|
+
assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query
|
150
|
+
assert_equal params[2], { 'query[person][position]' => 'prof' }.to_query
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_hash_recursive_and_array_parameters
|
154
|
+
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => 101, :query => {:person => {:name => 'Bob', :position => ['prof', 'art director']}, :hobby => 'piercing'})
|
155
|
+
assert_match %r(^/c/a/101), url
|
156
|
+
params = extract_params(url)
|
157
|
+
assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query
|
158
|
+
assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query
|
159
|
+
assert_equal params[2], { 'query[person][position][]' => 'art director' }.to_query
|
160
|
+
assert_equal params[3], { 'query[person][position][]' => 'prof' }.to_query
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_path_generation_for_symbol_parameter_keys
|
164
|
+
assert_generates("/image", :controller=> :image)
|
165
|
+
end
|
166
|
+
|
167
|
+
private
|
168
|
+
def extract_params(url)
|
169
|
+
url.split('?', 2).last.split('&')
|
170
|
+
end
|
127
171
|
end
|
@@ -36,14 +36,14 @@ class JavaScriptHelperTest < Test::Unit::TestCase
|
|
36
36
|
html = link_to_function( "Greet me!" ) do |page|
|
37
37
|
page.replace_html 'header', "<h1>Greetings</h1>"
|
38
38
|
end
|
39
|
-
assert_dom_equal %(<a href="#" onclick="Element.update("header", "
|
39
|
+
assert_dom_equal %q(<a href="#" onclick="Element.update("header", "\074h1\076Greetings\074/h1\076");; return false;">Greet me!</a>), html
|
40
40
|
end
|
41
41
|
|
42
42
|
def test_link_to_function_with_rjs_block_and_options
|
43
43
|
html = link_to_function( "Greet me!", :class => "updater" ) do |page|
|
44
44
|
page.replace_html 'header', "<h1>Greetings</h1>"
|
45
45
|
end
|
46
|
-
assert_dom_equal %(<a href="#" class="updater" onclick="Element.update("header", "
|
46
|
+
assert_dom_equal %q(<a href="#" class="updater" onclick="Element.update("header", "\074h1\076Greetings\074/h1\076");; return false;">Greet me!</a>), html
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_button_to_function
|
@@ -55,13 +55,13 @@ class JavaScriptHelperTest < Test::Unit::TestCase
|
|
55
55
|
html = button_to_function( "Greet me!" ) do |page|
|
56
56
|
page.replace_html 'header', "<h1>Greetings</h1>"
|
57
57
|
end
|
58
|
-
assert_dom_equal %(<input type="button" onclick="Element.update("header", "
|
58
|
+
assert_dom_equal %q(<input type="button" onclick="Element.update("header", "\074h1\076Greetings\074/h1\076");;" value="Greet me!" />), html
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_button_to_function_with_rjs_block_and_options
|
62
62
|
html = button_to_function( "Greet me!", :class => "greeter" ) do |page|
|
63
63
|
page.replace_html 'header', "<h1>Greetings</h1>"
|
64
64
|
end
|
65
|
-
assert_dom_equal %(<input type="button" class="greeter" onclick="Element.update("header", "
|
65
|
+
assert_dom_equal %q(<input type="button" class="greeter" onclick="Element.update("header", "\074h1\076Greetings\074/h1\076");;" value="Greet me!" />), html
|
66
66
|
end
|
67
67
|
end
|
@@ -170,23 +170,23 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase
|
|
170
170
|
end
|
171
171
|
|
172
172
|
def test_insert_html_with_string
|
173
|
-
assert_equal 'new Insertion.Top("element", "
|
173
|
+
assert_equal 'new Insertion.Top("element", "\074p\076This is a test\074/p\076");',
|
174
174
|
@generator.insert_html(:top, 'element', '<p>This is a test</p>')
|
175
|
-
assert_equal 'new Insertion.Bottom("element", "
|
175
|
+
assert_equal 'new Insertion.Bottom("element", "\074p\076This is a test\074/p\076");',
|
176
176
|
@generator.insert_html(:bottom, 'element', '<p>This is a test</p>')
|
177
|
-
assert_equal 'new Insertion.Before("element", "
|
177
|
+
assert_equal 'new Insertion.Before("element", "\074p\076This is a test\074/p\076");',
|
178
178
|
@generator.insert_html(:before, 'element', '<p>This is a test</p>')
|
179
|
-
assert_equal 'new Insertion.After("element", "
|
179
|
+
assert_equal 'new Insertion.After("element", "\074p\076This is a test\074/p\076");',
|
180
180
|
@generator.insert_html(:after, 'element', '<p>This is a test</p>')
|
181
181
|
end
|
182
182
|
|
183
183
|
def test_replace_html_with_string
|
184
|
-
assert_equal 'Element.update("element", "
|
184
|
+
assert_equal 'Element.update("element", "\074p\076This is a test\074/p\076");',
|
185
185
|
@generator.replace_html('element', '<p>This is a test</p>')
|
186
186
|
end
|
187
187
|
|
188
188
|
def test_replace_element_with_string
|
189
|
-
assert_equal 'Element.replace("element", "
|
189
|
+
assert_equal 'Element.replace("element", "\074div id=\"element\"\076\074p\076This is a test\074/p\076\074/div\076");',
|
190
190
|
@generator.replace('element', '<div id="element"><p>This is a test</p></div>')
|
191
191
|
end
|
192
192
|
|
@@ -241,12 +241,12 @@ class JavaScriptGeneratorTest < Test::Unit::TestCase
|
|
241
241
|
@generator.remove('foo', 'bar')
|
242
242
|
@generator.replace_html('baz', '<p>This is a test</p>')
|
243
243
|
|
244
|
-
|
245
|
-
new Insertion.
|
246
|
-
new Insertion.Bottom("element", "<p>This is a test</p>");
|
244
|
+
expected = %q(new Insertion.Top("element", "\074p\076This is a test\074/p\076");
|
245
|
+
new Insertion.Bottom("element", "\074p\076This is a test\074/p\076");
|
247
246
|
["foo", "bar"].each(Element.remove);
|
248
|
-
Element.update("baz", "
|
249
|
-
|
247
|
+
Element.update("baz", "\074p\076This is a test\074/p\076");)
|
248
|
+
|
249
|
+
assert_equal expected, @generator.to_s
|
250
250
|
end
|
251
251
|
|
252
252
|
def test_element_access
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionpack
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.13.
|
7
|
-
date: 2007-10-
|
6
|
+
version: 1.13.5
|
7
|
+
date: 2007-10-12 00:00:00 -05:00
|
8
8
|
summary: Web-flow and rendering framework putting the VC in MVC.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -377,5 +377,5 @@ dependencies:
|
|
377
377
|
requirements:
|
378
378
|
- - "="
|
379
379
|
- !ruby/object:Gem::Version
|
380
|
-
version: 1.4.
|
380
|
+
version: 1.4.4
|
381
381
|
version:
|