diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index 713850f97..c41ab3bad 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -188,8 +188,12 @@ func (t *ExecTool) guardCommand(command, cwd string) string { return "" } + // Strip URLs before path checking so they don't get misidentified as file paths + urlPattern := regexp.MustCompile(`[a-zA-Z][a-zA-Z0-9+.-]*://[^\s\"']+`) + stripped := urlPattern.ReplaceAllString(cmd, "") + pathPattern := regexp.MustCompile(`[A-Za-z]:\\[^\\\"']+|/[^\s\"']+`) - matches := pathPattern.FindAllString(cmd, -1) + matches := pathPattern.FindAllString(stripped, -1) for _, raw := range matches { p, err := filepath.Abs(raw)