lib/model: Sanitize paths used for auto accepted folders (fixes #5411) (#5435)

This commit is contained in:
Jakob Borg
2019-01-05 18:10:02 +01:00
committed by GitHub
parent f3630a69f1
commit 1e71b00936
2 changed files with 44 additions and 1 deletions

View File

@@ -3799,3 +3799,22 @@ func TestRequestLimit(t *testing.T) {
t.Fatalf("Second request did not return after first was done")
}
}
func TestSanitizePath(t *testing.T) {
cases := [][2]string{
{"", ""},
{"foo", "foo"},
{`\*/foo\?/bar[{!@$%^&*#()}]`, "foo bar ()"},
{"Räksmörgås", "Räksmörgås"},
{`Räk \/ smörgås`, "Räk smörgås"},
{"هذا هو *\x07?اسم الملف", "هذا هو اسم الملف"},
{`../foo.txt`, `.. foo.txt`},
}
for _, tc := range cases {
res := sanitizePath(tc[0])
if res != tc[1] {
t.Errorf("sanitizePath(%q) => %q, expected %q", tc[0], res, tc[1])
}
}
}