Created
April 20, 2009 04:09
-
-
Save rgrove/98356 to your computer and use it in GitHub Desktop.
Ramaze action cache vulnerable to collisions between controllers with identical method names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ramaze' | |
class MainController < Ramaze::Controller | |
map '/' | |
helper :cache | |
def index | |
%[ | |
<html> | |
<head><title>examples/caching</title></head> | |
<body> | |
<p> | |
This action just shows you a random number: #{rand * 100}.<br /> | |
If you <a href="/">refresh</a> the page it won't change since you see a cached version.<br /> | |
But if you <a href="/invalidate">invalidate</a> it, the page will be regenerated. | |
</p> | |
</body> | |
</html> | |
] | |
end | |
cache_action :method => :index | |
def invalidate | |
Ramaze::Cache.action.delete(:method => 'index') | |
redirect :/ | |
end | |
end | |
class FooController < Ramaze::Controller | |
map '/foo' | |
helper :cache | |
def index | |
(rand * 100).to_s | |
end | |
cache_action :method => :index | |
end | |
Ramaze.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment