From 2a111e573ed0a00362d4544ce6fb693378994332 Mon Sep 17 00:00:00 2001 From: Beaudene Date: Tue, 27 Oct 2026 08:07:04 +1300 Subject: [PATCH] fix(windows): accept native separators in relative file name checks --- internal/migration/apply.go | 2 +- internal/modules/resolved_file_observations.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/migration/apply.go b/internal/migration/apply.go index f35f8b97..026a6622 100644 --- a/internal/migration/apply.go +++ b/internal/migration/apply.go @@ -327,7 +327,7 @@ func sameSnapshot(before, after snapshot) bool { } func checkRelativeName(name string) error { - if !filepath.IsLocal(name) || name == "." || filepath.Clean(name) != name || strings.Contains(name, "\\") { + if !filepath.IsLocal(name) || name == "." || filepath.Clean(name) != name || (filepath.Separator != '\\' && strings.Contains(name, "\\")) { return fmt.Errorf("unsafe relative file name %q", name) } return nil diff --git a/internal/modules/resolved_file_observations.go b/internal/modules/resolved_file_observations.go index b38607a1..04566549 100644 --- a/internal/modules/resolved_file_observations.go +++ b/internal/modules/resolved_file_observations.go @@ -127,7 +127,7 @@ func (tx *resolvedFileObservations) capture(name string, allowed SourceRoots) (r } func (tx *resolvedFileObservations) readState(name string, allowed SourceRoots) (_ resolvedFileState, resultErr error) { - if !filepath.IsLocal(name) || name == "." || filepath.Clean(name) != name || strings.Contains(name, "\\") { + if !filepath.IsLocal(name) || name == "." || filepath.Clean(name) != name || (filepath.Separator != '\\' && strings.Contains(name, "\\")) { return resolvedFileState{}, fmt.Errorf("unsafe relative file name %q", name) } view, err := sourceview.NewLocal(tx.root.FS(), tx.canonicalRoot, tx.requestedRoot)