Permalink
Browse files

_ is not a valid scheme name character, \w includes it and also is re…

…dundant with \d.

'The scheme name consists of a letter followed by any combination of letters, digits, and the plus ("+"), period ("."), or hyphen ("-") characters; and is terminated by a colon (":").'
  • Loading branch information...
1 parent 8823b85 commit c37800aae123d21d53a49433cac2e0a2479c6bbd @miloops miloops committed Sep 29, 2010
@@ -81,7 +81,7 @@ 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
@request.protocol + @request.host_with_port + fragment
@@ -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'

0 comments on commit c37800a

Please sign in to comment.