From aa50ef406966f56a47e351c6b5539979d8383410 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 4 Jul 2016 10:44:30 +0000 Subject: [PATCH] lib/model: Invalidate files with trailing white space on Windows (fixes #3227) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3383 --- lib/protocol/nativemodel_windows.go | 2 +- lib/protocol/nativemodel_windows_test.go | 27 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 lib/protocol/nativemodel_windows_test.go diff --git a/lib/protocol/nativemodel_windows.go b/lib/protocol/nativemodel_windows.go index 29b092da2..2c76f294a 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 000000000..ef2a7757d --- /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