From df4862da84b9b8129eb53d455f196f28923fae5a Mon Sep 17 00:00:00 2001 From: ApolloF <98666317+ApolloF@users.noreply.github.com> Date: Sun, 4 Oct 2026 21:30:41 +0200 Subject: [PATCH] Reject short-name aliases with trailing dots or spaces --- internal/paths/real.go | 4 +++- internal/paths/real_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/paths/real.go b/internal/paths/real.go index 271b8c2..d874ec4 100644 --- a/internal/paths/real.go +++ b/internal/paths/real.go @@ -194,4 +194,6 @@ var shortNameForm = regexp.MustCompile(`~[0-9]+(\.[^.]*)?$`) // short name, which may stand for a folder of another name. Other names // with a "~" are fine: a real short name elsewhere is caught on disk by // CheckSyncable. -func LooksShort(name string) bool { return shortNameForm.MatchString(name) } +func LooksShort(name string) bool { + return shortNameForm.MatchString(strings.TrimRight(name, ". ")) +} diff --git a/internal/paths/real_test.go b/internal/paths/real_test.go index e7f2484..99145bb 100644 --- a/internal/paths/real_test.go +++ b/internal/paths/real_test.go @@ -88,7 +88,7 @@ func TestResolveShortNameForm(t *testing.T) { t.Errorf("Resolve(home, %q) refused", rel) } } - for _, rel := range []string{"PROGRA~1", "MICROS~1.TXT", "Games/SAVEGA~12", "a~1."} { + for _, rel := range []string{"PROGRA~1", "MICROS~1.TXT", "Games/SAVEGA~12", "a~1.", "PROGRA~1 ", "PROGRA~1..", "MICROS~1.TXT."} { if p, ok := Resolve(Home, rel); ok { t.Errorf("Resolve(home, %q) = %q, want refused", rel, p) }