diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 7 | ||||
-rw-r--r-- | actionpack/test/controller/request_test.rb | 10 |
3 files changed, 15 insertions, 4 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 386de83836..04e8a3130e 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Fix relative URL root matching problems. [Mark Imbriaco] + * Fix filter skipping in controller subclasses. #5949, #6297, #6299 [Martin Emde] * render_text may optionally append to the response body. render_javascript appends by default. This allows you to chain multiple render :update calls by setting @performed_render = false between them (awaiting a better public API). [Jeremy Kemper] diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index 35a486fee4..505fe0777f 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -161,11 +161,10 @@ module ActionController path = (uri = request_uri) ? uri.split('?').first : '' # Cut off the path to the installation directory if given - root = relative_url_root - path[0, root.length] = '' if root - path || '' + path.sub!(%r/^#{relative_url_root}/, '') + path || '' end - + # Returns the path minus the web server relative installation directory. # This can be set with the environment variable RAILS_RELATIVE_URL_ROOT. # It can be automatically extracted for Apache setups. If the server is not diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 9f79e7d6df..11da23561b 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -207,6 +207,16 @@ class RequestTest < Test::Unit::TestCase @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" assert_equal "/hieraki/", @request.request_uri assert_equal "/", @request.path + + @request.set_REQUEST_URI '/hieraki/dispatch.cgi' + @request.relative_url_root = '/hieraki' + assert_equal "/dispatch.cgi", @request.path + @request.relative_url_root = nil + + @request.set_REQUEST_URI '/hieraki/dispatch.cgi' + @request.relative_url_root = '/foo' + assert_equal "/hieraki/dispatch.cgi", @request.path + @request.relative_url_root = nil # This test ensures that Rails uses REQUEST_URI over PATH_INFO @request.relative_url_root = nil |