fix(tools): handle redirection and grouping delimiters in ExecTool path guard

This commit is contained in:
santhreal
2026-08-13 01:53:38 +09:00
committed by Xubin Ren
parent cd7480945b
commit 6fc0807fbf
2 changed files with 32 additions and 2 deletions
+9 -2
View File
@@ -1010,8 +1010,15 @@ class ExecTool(Tool):
r"(?<![A-Za-z])(?:[A-Za-z]:[^\s\"'|><;]*|\\\\[^\s\"'|><;]+(?:\\[^\s\"'|><;]+)*)",
command
)
posix_paths = re.findall(r"(?:^|[\s|>='\"])(/[^\s\"'>;|<]+)", command) # POSIX: /absolute only
home_paths = re.findall(r"(?:^|[\s>='\"])(~[/+][^\s\"'>;|<]*)", command) # POSIX/Windows home shortcut: ~/ or ~+
posix_paths = [
p.rstrip(");},")
for p in re.findall(r"(?:^|[\s|><='\"({,:])(/[^\"'>;|<()\s]+)", command)
if not p.startswith("//")
]
home_paths = [
p.rstrip(");},")
for p in re.findall(r"(?:^|[\s|><='\"({,:])(~[/+][^\"'>;|<()\s]+)", command)
]
return win_paths + posix_paths + home_paths
@staticmethod