fix: prevent learning mode from collapsing read paths to $HOME
Files directly under ~ (e.g., ~/.gitignore, ~/.npmrc) were collapsed to the home directory, defeating sandboxing. Now keeps exact file paths when the parent directory would be $HOME.
This commit is contained in:
@@ -220,9 +220,15 @@ func CollapsePaths(paths []string) []string {
|
||||
}
|
||||
}
|
||||
|
||||
// For standalone paths, use their parent directory
|
||||
// For standalone paths, use their parent directory — but never collapse to $HOME
|
||||
for _, p := range standalone {
|
||||
result = append(result, filepath.Dir(p))
|
||||
parent := filepath.Dir(p)
|
||||
if parent == home {
|
||||
// Keep exact file path to avoid opening entire home directory
|
||||
result = append(result, p)
|
||||
} else {
|
||||
result = append(result, parent)
|
||||
}
|
||||
}
|
||||
|
||||
// Sort and deduplicate (remove sub-paths of other paths)
|
||||
|
||||
Reference in New Issue
Block a user