aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Claghorn <george.claghorn@gmail.com>2017-10-08 17:30:43 -0400
committerGitHub <noreply@github.com>2017-10-08 17:30:43 -0400
commitf165628cdf9a6d857ea6eeca02ed6c950b250df5 (patch)
treed335a44dc7b2d8cc5ab165c8c4f687272419266d
parent7c564d87408ca1e205d34574228d6f981c7571c8 (diff)
parentead60686e810df4b49bf19f4f113b48f16ae560f (diff)
downloadrails-f165628cdf9a6d857ea6eeca02ed6c950b250df5.tar.gz
rails-f165628cdf9a6d857ea6eeca02ed6c950b250df5.tar.bz2
rails-f165628cdf9a6d857ea6eeca02ed6c950b250df5.zip
Merge pull request #30802 from khall/30662_long_variant_filenames
Break long variant filenames into path chunks
-rw-r--r--activestorage/app/models/active_storage/variant.rb2
-rw-r--r--activestorage/test/models/variant_test.rb5
2 files changed, 6 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
diff --git a/activestorage/test/models/variant_test.rb b/activestorage/test/models/variant_test.rb
index d7cbef4e55..b7d20ab55a 100644
--- a/activestorage/test/models/variant_test.rb
+++ b/activestorage/test/models/variant_test.rb
@@ -26,4 +26,9 @@ class ActiveStorage::VariantTest < ActiveSupport::TestCase
assert_equal 67, image.height
assert_match(/Gray/, image.colorspace)
end
+
+ test "service_url doesn't grow in length despite long variant options" do
+ variant = @blob.variant(font: "a" * 10_000).processed
+ assert_operator variant.service_url.length, :<, 500
+ end
end