diff --git a/wwwroot/api/cockpit_chat.dspy b/wwwroot/api/cockpit_chat.dspy index 2e142be..0ea7bfd 100644 --- a/wwwroot/api/cockpit_chat.dspy +++ b/wwwroot/api/cockpit_chat.dspy @@ -888,7 +888,12 @@ if action == 'send_message': m = re.search(r'(git@[\w.]+:[\w./-]+\.git|https?://[\w./-]+\.git)', cmd) repo_url = m.group(0) rest = cmd[m.end():].strip() - target = rest.split()[0] if rest else '' + # target 只接受合法路径片段(字母数字/-_.),拒绝中文 + target = '' + if rest: + first_token = rest.split()[0] if rest.split() else '' + if first_token and re.match(r'^[a-zA-Z0-9/_.-]+$', first_token): + target = first_token if target and not target.startswith('-'): repo_target = target cmd = f'git clone {repo_url} {target}'