public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fixed regex in redirect_to to fully support URI schemes [#1247 state:committed]

Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
mojodna (author)
Thu Oct 30 12:03:47 -0700 2008
dhh (committer)
Thu Oct 30 13:07:50 -0700 2008
commit  47b4fa4a621ee48ab17545b1e9fb38efef53b28e
tree    2cf5c92154ff0cdefb4b09e16cb788802369cb4b
parent  ef53d915164da7f757d03c4a70fe38e374c08b14
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *2.2.1 [RC2 or 2.2 final]*
0
 
0
+* Fixed regex in redirect_to to fully support URI schemes #1247 [Seth Fitzsimmons]
0
+
0
 * Fixed bug with asset timestamping when using relative_url_root #1265 [Joe Goldwasser]
0
 
0
 
...
1053
1054
1055
1056
 
 
 
 
1057
1058
1059
...
1053
1054
1055
 
1056
1057
1058
1059
1060
1061
1062
0
@@ -1053,7 +1053,10 @@ module ActionController #:nodoc:
0
         logger.info("Redirected to #{options}") if logger && logger.info?
0
 
0
         case options
0
-          when %r{^\w+://.*}
0
+          # The scheme name consist of a letter followed by any combination of
0
+          # letters, digits, and the plus ("+"), period ("."), or hyphen ("-")
0
+          # characters; and is terminated by a colon (":").
0
+          when %r{^\w[\w\d+.-]*:.*}
0
             redirect_to_full_url(options, status)
0
           when String
0
             redirect_to_full_url(request.protocol + request.host_with_port + options, status)
...
73
74
75
 
 
 
 
76
77
78
...
198
199
200
 
 
 
 
 
 
201
202
203
...
73
74
75
76
77
78
79
80
81
82
...
202
203
204
205
206
207
208
209
210
211
212
213
0
@@ -73,6 +73,10 @@ class RedirectController < ActionController::Base
0
     redirect_to "http://dev.rubyonrails.org/query?status=new"
0
   end
0
 
0
+  def redirect_to_url_with_complex_scheme
0
+    redirect_to "x-test+scheme.complex:redirect"
0
+  end
0
+
0
   def redirect_to_back
0
     redirect_to :back
0
   end
0
@@ -198,6 +202,12 @@ class RedirectTest < Test::Unit::TestCase
0
     assert_redirected_to "http://dev.rubyonrails.org/query?status=new"
0
   end
0
 
0
+  def test_redirect_to_url_with_complex_scheme
0
+    get :redirect_to_url_with_complex_scheme
0
+    assert_response :redirect
0
+    assert_equal "x-test+scheme.complex:redirect", redirect_to_url
0
+  end
0
+
0
   def test_redirect_to_back
0
     @request.env["HTTP_REFERER"] = "http://www.example.com/coming/from"
0
     get :redirect_to_back

Comments