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)
176176
177177 # Translate a file path into a key.
178178 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 )
180180 URI . decode_www_form_component ( fname , Encoding ::UTF_8 )
181181 end
182182
Original file line number Diff line number Diff line change @@ -91,6 +91,18 @@ def test_key_transformation_max_filename_size
9191 assert_equal "B" , File . basename ( path )
9292 end
9393
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+
94106 # If nothing has been stored in the cache, there is a chance the cache directory does not yet exist
95107 # Ensure delete_matched gracefully handles this case
96108 def test_delete_matched_when_cache_directory_does_not_exist
You can’t perform that action at this time.
0 commit comments