mirror of
https://github.com/restic/rest-server.git
synced 2025-12-06 17:15:45 -08:00
Minor cleanup and fixes
- Do not allow '.' as path component, because it undermines depth checks, and add tests - Fix GiB reporting - Fix metrics label - Helper function for http errors
This commit is contained in:
committed by
Alexander Neumann
parent
1f593fafaf
commit
d4cd47e503
@@ -248,10 +248,18 @@ func TestSplitURLPath(t *testing.T) {
|
||||
{"/foo/bar/zzz/locks/0123", 2, []string{"foo", "bar"}, "/zzz/locks/0123"},
|
||||
{"/foo/bar/zzz/locks/0123", 3, []string{"foo", "bar", "zzz"}, "/locks/0123"},
|
||||
{"/foo/bar/locks/", 2, []string{"foo", "bar"}, "/locks/"},
|
||||
{"/foo/locks/", 2, []string{"foo"}, "/locks/"},
|
||||
{"/foo/data/", 2, []string{"foo"}, "/data/"},
|
||||
{"/foo/index/", 2, []string{"foo"}, "/index/"},
|
||||
{"/foo/keys/", 2, []string{"foo"}, "/keys/"},
|
||||
{"/foo/snapshots/", 2, []string{"foo"}, "/snapshots/"},
|
||||
{"/foo/config", 2, []string{"foo"}, "/config"},
|
||||
{"/foo/", 2, []string{"foo"}, "/"},
|
||||
{"/foo/bar/", 2, []string{"foo", "bar"}, "/"},
|
||||
{"/foo/bar", 2, []string{"foo"}, "/bar"},
|
||||
{"/locks/", 2, nil, "/locks/"},
|
||||
// This function only splits, it does not check the path components!
|
||||
{"/././locks/", 2, []string{"..", ".."}, "/locks/"},
|
||||
{"/../../locks/", 2, []string{"..", ".."}, "/locks/"},
|
||||
{"///locks/", 2, []string{"", ""}, "/locks/"},
|
||||
{"////locks/", 2, []string{"", ""}, "//locks/"},
|
||||
|
||||
Reference in New Issue
Block a user