Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8226

Show
Ignore:
Timestamp:
11/28/07 00:29:43 (1 year ago)
Author:
david
Message:

Added protection from trailing slashes on page caching (closes #10229) [devrieda]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r8220 r8226  
    11*SVN* 
     2 
     3* Added protection from trailing slashes on page caching #10229 [devrieda] 
    24 
    35* Asset timestamps are appended, not prepended. Closes #10276 [mnaberez] 
  • trunk/actionpack/lib/action_controller/caching.rb

    r8001 r8226  
    107107        private 
    108108          def page_cache_file(path) 
    109             name = ((path.empty? || path == "/") ? "/index" : URI.unescape(path)) 
     109            name = (path.empty? || path == "/") ? "/index" : URI.unescape(path.chomp('/')) 
    110110            name << page_cache_extension unless (name.split('/').last || name).include? '.' 
    111111            return name 
  • trunk/actionpack/test/controller/caching_test.rb

    r8164 r8226  
    3636    head :ok 
    3737  end 
     38   
     39  def trailing_slash 
     40    render :text => "Sneak attack" 
     41  end 
    3842end 
    3943 
     
    9195    get :expire_custom_path 
    9296    assert !File.exist?("#{FILE_STORE_PATH}/index.html") 
     97  end 
     98   
     99  def test_should_cache_without_trailing_slash_on_url 
     100    @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash' 
     101    assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") 
     102  end 
     103 
     104  def test_should_cache_with_trailing_slash_on_url 
     105    @controller.class.cache_page 'cached content', '/page_caching_test/trailing_slash/' 
     106    assert File.exist?("#{FILE_STORE_PATH}/page_caching_test/trailing_slash.html") 
    93107  end 
    94108