Skip to content

Commit 5a47de1

Browse files
wesmclaude
andcommitted
Fix overly broad ".." prefix check in cursor containment
validateCursorContainment and FindCursorSourceFile used strings.HasPrefix(rel, "..") which rejects valid paths like "..config/". Use separator-aware check matching isContainedIn. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9ba3e5b commit 5a47de1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

internal/sync/discovery.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,9 @@ func FindCursorSourceFile(
570570
continue
571571
}
572572
rel, err := filepath.Rel(resolvedRoot, resolved)
573-
if err != nil || strings.HasPrefix(rel, "..") {
573+
sep := string(filepath.Separator)
574+
if err != nil || rel == ".." ||
575+
strings.HasPrefix(rel, ".."+sep) {
574576
continue
575577
}
576578
return candidate

internal/sync/engine.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,9 @@ func validateCursorContainment(
11321132
return fmt.Errorf("resolve path: %w", err)
11331133
}
11341134
rel, err := filepath.Rel(resolvedRoot, resolvedPath)
1135-
if err != nil || strings.HasPrefix(rel, "..") {
1135+
sep := string(filepath.Separator)
1136+
if err != nil || rel == ".." ||
1137+
strings.HasPrefix(rel, ".."+sep) {
11361138
return fmt.Errorf(
11371139
"%s escapes %s", path, cursorDir,
11381140
)

0 commit comments

Comments
 (0)