GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
FilesystemSynchronousBackend uses FilePath.child() to resolve the requested file to a file on disk. However, FilePath.child() rejects paths containing directory separators.
I suppose, there will be no harm in allowing unlimited "downwards" traversal (that is allow requests of any files that are actually beneath base). The fix is really simple so all I need it to write a couple of tests for this new case and that's all.
On the second thought, though, what would one do when requesting a write to a directory that is beneath base, but which path contains fragment that don't exist on the file system. Say, base is /foo, which is an empty directory and one requests a write to /foo/bar/baz, which is "kind of" safe, but one expects from the backend in this case? To create missing fragments? Indicate an error ("File not found" or "Access violation" seem to be suitable error types)? I am not sure, to be honest
This change is opinionated in that regard: it creates those directories. A further change could make this configurable. We're only using the server for reads, so the write support for nested directories was done only for completeness; it wouldn't affect me to remove the makedirs() call and return an error instead.