Permalink
Browse files

Merge remote branch 'miloops/warnings'

  • Loading branch information...
2 parents a617f6b + 6371e5b commit d2ea2e1d5f0964866c4e333a4128049df8927d63 @josevalim josevalim committed Sep 29, 2010
@@ -349,7 +349,7 @@ def redirect(*args, &block)
options = args.last.is_a?(Hash) ? args.pop : {}
path = args.shift || block
- path_proc = path.is_a?(Proc) ? path : proc { |params| params.empty? ? path : (path % params) }
+ path_proc = path.is_a?(Proc) ? path : proc { |params| (params.empty? || !path.match(/%{\w*}/)) ? path : (path % params) }
status = options[:status] || 301
lambda do |env|
@@ -81,14 +81,10 @@ def parameterize(value)
def normalize_argument_to_redirection(fragment)
case fragment
- when %r{^\w[\w\d+.-]*:.*}
+ when %r{^\w[A-Za-z\d+.-]*:.*}
fragment
when String
- if fragment =~ %r{^\w[\w\d+.-]*:.*}
- fragment
- else
- @request.protocol + @request.host_with_port + fragment
- end
+ @request.protocol + @request.host_with_port + fragment
when :back
raise RedirectBackError unless refer = @request.headers["Referer"]
refer
@@ -32,6 +32,8 @@ def redirect_to_controller_with_symbol() redirect_to :controller => :elsewhere,
def redirect_to_path() redirect_to '/some/path' end
+ def redirect_invalid_external_route() redirect_to 'ht_tp://www.rubyonrails.org' end
+
def redirect_to_named_route() redirect_to route_one_url end
def redirect_external() redirect_to "http://www.rubyonrails.org"; end
@@ -368,6 +370,11 @@ def test_redirected_to_url_no_leading_slash_fails
end
end
+ def test_redirect_invalid_external_route
+ process :redirect_invalid_external_route
+ assert_redirected_to "http://test.hostht_tp://www.rubyonrails.org"
+ end
+
def test_redirected_to_url_full_url
process :redirect_to_path
assert_redirected_to 'http://test.host/some/path'
@@ -25,6 +25,10 @@ def non_erb_block_content_for
render :layout => "talk_from_action"
end
+ def proper_block_detection
+ @todo = "some todo"
+ end
+
def rescue_action(e) raise end
end
@@ -66,8 +70,8 @@ def test_non_erb_block_content_for
end
def test_proper_block_detection
- @todo = "some todo"
get :proper_block_detection
+ assert_equal "some todo", @response.body
end
private
@@ -314,6 +314,7 @@ class MixedFilterController < PrependingController
def initialize
@@execution_log = ""
+ super()
end
before_filter { |c| c.class.execution_log << " before procfilter " }
@@ -1 +1 @@
-<%= @todo %>
+<%= @todo %>

0 comments on commit d2ea2e1

Please sign in to comment.