Skip to content

FileCache should either reject or consistently fix keys that conflict as filepaths #58

Description

@palenshus

Currently the library allows you to specify invalid Windows filepaths as keys, for example:

var cache = new FileCache(".");

cache.Add("foo", "foo", DateTimeOffset.Now.AddMinutes(1));
cache.Get("foo").Dump();		// Returns "foo"
cache.Get("foo.bar").Dump();	// Also returns "foo", because the key is truncated, should return null

cache.Add(@"foo\bar", @"foo\bar", DateTimeOffset.Now.AddMinutes(1));
cache.Get(@"foo\bar").Dump();  // Returns "foo\bar"
cache.Get(@"bar").Dump();      // Also returns "foo\bar", should return null.

I'd propose that either the library should reject these as keys (if the input string != the filename), or IMO better yet it should transform them to be eligible paths. Though in this case, care must be taken so that the transformed paths don't conflict with other non-transformed keys.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions