lib/protocol: Apply input filtering on file names
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3775
This commit is contained in:
29
lib/protocol/nativemodel_windows_test.go
Normal file
29
lib/protocol/nativemodel_windows_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2016 The Protocol Authors.
|
||||
|
||||
package protocol
|
||||
|
||||
import "testing"
|
||||
import "reflect"
|
||||
|
||||
func TestFixupFiles(t *testing.T) {
|
||||
files := []FileInfo{
|
||||
{Name: "foo/bar"},
|
||||
{Name: `foo\bar`},
|
||||
{Name: "foo/baz"},
|
||||
{Name: "foo/quux"},
|
||||
{Name: `foo\fail`},
|
||||
}
|
||||
|
||||
// Filenames should be slash converted, except files which already have
|
||||
// backslashes in them which are instead filtered out.
|
||||
expected := []FileInfo{
|
||||
{Name: `foo\bar`},
|
||||
{Name: `foo\baz`},
|
||||
{Name: `foo\quux`},
|
||||
}
|
||||
|
||||
fixed := fixupFiles(files)
|
||||
if !reflect.DeepEqual(fixed, expected) {
|
||||
t.Errorf("Got %v, expected %v", fixed, expected)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user