diff options
author | khall <kevinmichaelhall@gmail.com> | 2017-10-04 12:26:04 -0700 |
---|---|---|
committer | khall <kevinmichaelhall@gmail.com> | 2017-10-05 20:57:33 -0700 |
commit | ead60686e810df4b49bf19f4f113b48f16ae560f (patch) | |
tree | 4792706af93e46d4edb7a952160152efadc265ed /activestorage/app | |
parent | bd2542b74fe528d95f51d8f3668b0f7d6d8af974 (diff) | |
download | rails-ead60686e810df4b49bf19f4f113b48f16ae560f.tar.gz rails-ead60686e810df4b49bf19f4f113b48f16ae560f.tar.bz2 rails-ead60686e810df4b49bf19f4f113b48f16ae560f.zip |
Replace variation key use with SHA256 of key to prevent long filenames
If a variant has a large set of options associated with it, the generated
filename will be too long, causing Errno::ENAMETOOLONG to be raised. This
change replaces those potentially long filenames with a much more compact
SHA256 hash. Fixes #30662.
Diffstat (limited to 'activestorage/app')
-rw-r--r-- | activestorage/app/models/active_storage/variant.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activestorage/app/models/active_storage/variant.rb b/activestorage/app/models/active_storage/variant.rb index 54685b4c0e..90a3605331 100644 --- a/activestorage/app/models/active_storage/variant.rb +++ b/activestorage/app/models/active_storage/variant.rb @@ -50,7 +50,7 @@ class ActiveStorage::Variant # Returns a combination key of the blob and the variation that together identifies a specific variant. def key - "variants/#{blob.key}/#{variation.key}" + "variants/#{blob.key}/#{Digest::SHA256.hexdigest(variation.key)}" end # Returns the URL of the variant on the service. This URL is intended to be short-lived for security and not used directly |