Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a separator to the cache key for ActiveSupport::CachingKeyGenerator #39143

Merged
merged 1 commit into from May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/key_generator.rb
Expand Up @@ -35,7 +35,7 @@ def initialize(key_generator)

# Returns a derived key suitable for use.
def generate_key(*args)
@cache_keys[args.join] ||= @key_generator.generate_key(*args)
@cache_keys[args.join('|')] ||= @key_generator.generate_key(*args)
end
end
end
7 changes: 7 additions & 0 deletions activesupport/test/key_generator_test.rb
Expand Up @@ -71,6 +71,13 @@ def setup

assert_not_equal derived_key, different_length_key
end

test "Does not cache key for different salts and lengths that are different but are equal when concatenated" do
derived_key = @caching_generator.generate_key("13", 37)
different_length_key = @caching_generator.generate_key("1", 337)

assert_not_equal derived_key, different_length_key
end
end

end