diff options
author | Denis Odorcic <denis.odorcic@gmail.com> | 2010-10-23 00:55:17 -0400 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-07 20:01:51 -0200 |
commit | c452d734f202fef3560173cd10701be8ff1a057b (patch) | |
tree | 8ee326d568d56e09b2aba2b2e09d50bfce7c1f7c /activesupport/lib/active_support/cache | |
parent | 3d6eea0221f0092cb3c3270c2a9bdf31745d1b2d (diff) | |
download | rails-c452d734f202fef3560173cd10701be8ff1a057b.tar.gz rails-c452d734f202fef3560173cd10701be8ff1a057b.tar.bz2 rails-c452d734f202fef3560173cd10701be8ff1a057b.zip |
Fix FileStore cache incorrectly regenerating its key from a pathname when a regexp is used in expire_fragment
[#5850 state:committed]
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activesupport/lib/active_support/cache')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index 84f6f29572..18182bbb40 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -1,5 +1,6 @@ require 'active_support/core_ext/file/atomic' require 'active_support/core_ext/string/conversions' +require 'rack/utils' module ActiveSupport module Cache @@ -11,8 +12,6 @@ module ActiveSupport attr_reader :cache_path DIR_FORMATTER = "%03X" - ESCAPE_FILENAME_CHARS = /[^a-z0-9_.-]/i - UNESCAPE_FILENAME_CHARS = /%[0-9A-F]{2}/ def initialize(cache_path, options = nil) super(options) @@ -136,7 +135,7 @@ module ActiveSupport # Translate a key into a file path. def key_file_path(key) - fname = key.to_s.gsub(ESCAPE_FILENAME_CHARS){|match| "%#{match.ord.to_s(16).upcase}"} + fname = Rack::Utils.escape(key) hash = Zlib.adler32(fname) hash, dir_1 = hash.divmod(0x1000) dir_2 = hash.modulo(0x1000) @@ -156,7 +155,7 @@ module ActiveSupport # Translate a file path into a key. def file_path_key(path) fname = path[cache_path.size, path.size].split(File::SEPARATOR, 4).last - fname.gsub(UNESCAPE_FILENAME_CHARS){|match| $1.ord.to_s(16)} + Rack::Utils.unescape(fname) end # Delete empty directories in the cache. |