summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Borg <jakob@nym.se>2016-07-04 10:44:30 +0000
committerJakob Borg <jakob@nym.se>2016-07-04 13:37:43 +0200
commit8a64883355c306aaca694a51eb72fb4229eff9e4 (patch)
tree2d3847a19b03bef458366237e6ced31ccc1679ac
parent21f5b16e47a57ca134228b3ac627126f1b6a1581 (diff)
lib/model: Invalidate files with trailing white space on Windows (fixes #3227)v0.13
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3383
-rw-r--r--lib/protocol/nativemodel_windows.go2
-rw-r--r--lib/protocol/nativemodel_windows_test.go27
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/protocol/nativemodel_windows.go b/lib/protocol/nativemodel_windows.go
index 186ddfa7fe..292aed0ad8 100644
--- a/lib/protocol/nativemodel_windows.go
+++ b/lib/protocol/nativemodel_windows.go
@@ -41,7 +41,7 @@ func (m nativeModel) Request(deviceID DeviceID, folder string, name string, offs
func fixupFiles(folder string, files []FileInfo) {
for i, f := range files {
- if strings.ContainsAny(f.Name, disallowedCharacters) {
+ if strings.ContainsAny(f.Name, disallowedCharacters) || strings.HasSuffix(f.Name, " ") {
if f.IsDeleted() {
// Don't complain if the file is marked as deleted, since it
// can't possibly exist here anyway.
diff --git a/lib/protocol/nativemodel_windows_test.go b/lib/protocol/nativemodel_windows_test.go
new file mode 100644
index 0000000000..ef2a7757d8
--- /dev/null
+++ b/lib/protocol/nativemodel_windows_test.go
@@ -0,0 +1,27 @@
+// Copyright (C) 2016 The Protocol Authors.
+
+// +build windows
+
+package protocol
+
+import "testing"
+
+func TestFixupFiles(t *testing.T) {
+ fs := []FileInfo{
+ {Name: "ok"}, // This file is OK
+ {Name: "b<d"}, // The rest should be marked as invalid
+ {Name: "b?d"},
+ {Name: "bad "},
+ }
+
+ fixupFiles("default", fs)
+
+ if fs[0].IsInvalid() {
+ t.Error("fs[0] should not be invalid")
+ }
+ for i := 1; i < len(fs); i++ {
+ if !fs[i].IsInvalid() {
+ t.Errorf("fs[%d] should be invalid", i)
+ }
+ }
+}