File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ def normalize_key(key, options)
176
176
177
177
# Translate a file path into a key.
178
178
def file_path_key ( path )
179
- fname = path [ cache_path . to_s . size ..-1 ] . split ( File ::SEPARATOR , 4 ) . last
179
+ fname = path [ cache_path . to_s . size ..-1 ] . split ( File ::SEPARATOR , 4 ) . last . delete ( File :: SEPARATOR )
180
180
URI . decode_www_form_component ( fname , Encoding ::UTF_8 )
181
181
end
182
182
Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ def test_key_transformation_max_filename_size
91
91
assert_equal "B" , File . basename ( path )
92
92
end
93
93
94
+ def test_delete_matched_when_key_exceeds_max_filename_size
95
+ submaximal_key = "_" * ( ActiveSupport ::Cache ::FileStore ::FILENAME_MAX_SIZE - 1 )
96
+
97
+ @cache . write ( submaximal_key + "AB" , "value" )
98
+ @cache . delete_matched ( /AB/ )
99
+ assert_not @cache . exist? ( submaximal_key + "AB" )
100
+
101
+ @cache . write ( submaximal_key + "/A" , "value" )
102
+ @cache . delete_matched ( /A/ )
103
+ assert_not @cache . exist? ( submaximal_key + "/A" )
104
+ end
105
+
94
106
# If nothing has been stored in the cache, there is a chance the cache directory does not yet exist
95
107
# Ensure delete_matched gracefully handles this case
96
108
def test_delete_matched_when_cache_directory_does_not_exist
You can’t perform that action at this time.
0 commit comments