mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Revert "Merge pull request #20584 from arthurnn/fix_url"
This reverts commit0b33978725
, reversing changes made to56d52e3749
. As pointed out on the PR, this will hide development mistakes too, which is not ideal.
This commit is contained in:
parent
15de4b6d1e
commit
ffba8f79a2
3 changed files with 4 additions and 19 deletions
|
@ -1,7 +1,3 @@
|
||||||
* Handle InvalidURIError on bad paths on redirect route.
|
|
||||||
|
|
||||||
*arthurnn*
|
|
||||||
|
|
||||||
* Deprecate passing first parameter as `Hash` and default status code for `head` method.
|
* Deprecate passing first parameter as `Hash` and default status code for `head` method.
|
||||||
|
|
||||||
*Mehmet Emin İNAÇ*
|
*Mehmet Emin İNAÇ*
|
||||||
|
|
|
@ -23,12 +23,8 @@ module ActionDispatch
|
||||||
|
|
||||||
def serve(req)
|
def serve(req)
|
||||||
req.check_path_parameters!
|
req.check_path_parameters!
|
||||||
begin
|
uri = URI.parse(path(req.path_parameters, req))
|
||||||
uri = URI.parse(path(req.path_parameters, req))
|
|
||||||
rescue URI::InvalidURIError
|
|
||||||
return [ 400, {}, ['Invalid path.'] ]
|
|
||||||
end
|
|
||||||
|
|
||||||
unless uri.host
|
unless uri.host
|
||||||
if relative_path?(uri.path)
|
if relative_path?(uri.path)
|
||||||
uri.path = "#{req.script_name}/#{uri.path}"
|
uri.path = "#{req.script_name}/#{uri.path}"
|
||||||
|
@ -36,7 +32,7 @@ module ActionDispatch
|
||||||
uri.path = req.script_name.empty? ? "/" : req.script_name
|
uri.path = req.script_name.empty? ? "/" : req.script_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
uri.scheme ||= req.scheme
|
uri.scheme ||= req.scheme
|
||||||
uri.host ||= req.host
|
uri.host ||= req.host
|
||||||
uri.port ||= req.port unless req.standard_port?
|
uri.port ||= req.port unless req.standard_port?
|
||||||
|
@ -128,7 +124,7 @@ module ActionDispatch
|
||||||
url_options[:script_name] = request.script_name
|
url_options[:script_name] = request.script_name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
ActionDispatch::Http::URL.url_for url_options
|
ActionDispatch::Http::URL.url_for url_options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -219,13 +219,6 @@ module ActionDispatch
|
||||||
assert_equal 404, resp.first
|
assert_equal 404, resp.first
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_invalid_url_path
|
|
||||||
routes = Class.new { include ActionDispatch::Routing::Redirection }.new
|
|
||||||
route = routes.redirect("/foo/bar/%{id}")
|
|
||||||
resp = route.serve(rails_env({ 'REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/foo/(function(){})' }))
|
|
||||||
assert_equal 400, resp.first
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_clear_trailing_slash_from_script_name_on_root_unanchored_routes
|
def test_clear_trailing_slash_from_script_name_on_root_unanchored_routes
|
||||||
route_set = Routing::RouteSet.new
|
route_set = Routing::RouteSet.new
|
||||||
mapper = Routing::Mapper.new route_set
|
mapper = Routing::Mapper.new route_set
|
||||||
|
|
Loading…
Reference in a new issue