diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 17:03:48 -0600 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-10-20 17:03:48 -0600 |
commit | 28129174f0b3eeaf644a7f00a89a76869960d672 (patch) | |
tree | 669e22f60b5fcf20f8c7b22f107fc584c2cbbaaa /activesupport/lib | |
parent | 6ae515d1bf1fe60527b010ffd35314470000e864 (diff) | |
parent | 2b5a8bc1868aedcd8dcb84c906792207282ae303 (diff) | |
download | rails-28129174f0b3eeaf644a7f00a89a76869960d672.tar.gz rails-28129174f0b3eeaf644a7f00a89a76869960d672.tar.bz2 rails-28129174f0b3eeaf644a7f00a89a76869960d672.zip |
Merge pull request #19889 from cedrics/long-uri-encoded-keys
FileStore: Long cache keys may result in too long paths due to encoding
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/cache/file_store.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/cache/file_store.rb b/activesupport/lib/active_support/cache/file_store.rb index e6a8b84214..b7da30123a 100644 --- a/activesupport/lib/active_support/cache/file_store.rb +++ b/activesupport/lib/active_support/cache/file_store.rb @@ -119,11 +119,12 @@ module ActiveSupport # Translate a key into a file path. def key_file_path(key) - if key.size > FILEPATH_MAX_SIZE - key = Digest::MD5.hexdigest(key) + fname = URI.encode_www_form_component(key) + + if fname.size > FILEPATH_MAX_SIZE + fname = Digest::MD5.hexdigest(key) end - fname = URI.encode_www_form_component(key) hash = Zlib.adler32(fname) hash, dir_1 = hash.divmod(0x1000) dir_2 = hash.modulo(0x1000) |