diff --git a/wwwroot/api/workspace_file.dspy b/wwwroot/api/workspace_file.dspy index aaa3577..54374f9 100644 --- a/wwwroot/api/workspace_file.dspy +++ b/wwwroot/api/workspace_file.dspy @@ -2,17 +2,13 @@ action = (params_kw or {}).get('action', 'read') filepath = (params_kw or {}).get('path', '').strip() -workspace_base = '/d/pipeline/workspaces' - -# 安全检查 -if not filepath or not filepath.startswith(workspace_base): - return json.dumps({"error": "路径不合法"}, ensure_ascii=False) import os +if not filepath or not os.path.isfile(filepath): + return json.dumps({"error": "文件不存在: " + filepath}, ensure_ascii=False) + if action == 'read': - if not os.path.isfile(filepath): - return json.dumps({"error": "文件不存在"}, ensure_ascii=False) try: with open(filepath, 'r', encoding='utf-8') as f: content = f.read(50000)