Added protection from trailing slashes on page caching (closes #10229) [devrieda]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8226 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
4d177ae0d6
commit
45d679bcb8
|
@ -1,5 +1,7 @@
|
||||||
*SVN*
|
*SVN*
|
||||||
|
|
||||||
|
* Added protection from trailing slashes on page caching #10229 [devrieda]
|
||||||
|
|
||||||
* Asset timestamps are appended, not prepended. Closes #10276 [mnaberez]
|
* Asset timestamps are appended, not prepended. Closes #10276 [mnaberez]
|
||||||
|
|
||||||
* Minor inconsistency in description of render example. Closes #10029 [ScottSchram]
|
* Minor inconsistency in description of render example. Closes #10029 [ScottSchram]
|
||||||
|
|
|
@ -106,7 +106,7 @@ module ActionController #:nodoc:
|
||||||
|
|
||||||
private
|
private
|
||||||
def page_cache_file(path)
|
def page_cache_file(path)
|
||||||
name = ((path.empty? || path == "/") ? "/index" : URI.unescape(path))
|
name = (path.empty? || path == "/") ? "/index" : URI.unescape(path.chomp('/'))
|
||||||
name << page_cache_extension unless (name.split('/').last || name).include? '.'
|
name << page_cache_extension unless (name.split('/').last || name).include? '.'
|
||||||
return name
|
return name
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,6 +35,10 @@ class PageCachingTestController < ActionController::Base
|
||||||
expire_page("/index.html")
|
expire_page("/index.html")
|
||||||
head :ok
|
head :ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def trailing_slash
|
||||||
|
render :text => "Sneak attack"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class PageCachingTest < Test::Unit::TestCase
|
class PageCachingTest < Test::Unit::TestCase
|
||||||
|
@ -92,6 +96,16 @@ class PageCachingTest < Test::Unit::TestCase
|
||||||
assert !File.exist?("#{FILE_STORE_PATH}/index.html")
|
assert !File.exist?("#{FILE_STORE_PATH}/index.html")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_should_cache_without_trailing_slash_on_url
|
||||||
|
@controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash'
|
||||||
|
assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html")
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_should_cache_with_trailing_slash_on_url
|
||||||
|
@controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash/'
|
||||||
|
assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html")
|
||||||
|
end
|
||||||
|
|
||||||
uses_mocha("should_cache_ok_at_custom_path") do
|
uses_mocha("should_cache_ok_at_custom_path") do
|
||||||
def test_should_cache_ok_at_custom_path
|
def test_should_cache_ok_at_custom_path
|
||||||
@request.expects(:path).returns("/index.html")
|
@request.expects(:path).returns("/index.html")
|
||||||
|
|
Loading…
Reference in New Issue