File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616from ..parser_loader import load_parsers
1717from ..schemas import EditResult
1818from ..types_defs import FunctionMatch
19+ from ..utils .path_utils import validate_allowed_path
1920from . import tool_descriptions as td
2021
2122
@@ -212,8 +213,9 @@ def replace_code_block(
212213
213214 logger .info (ls .TOOL_FILE_EDIT_SURGICAL .format (path = file_path ))
214215 try :
215- full_path = (self .project_root / file_path ).resolve ()
216- full_path .relative_to (self .project_root )
216+ full_path = validate_allowed_path (
217+ file_path , self .project_root , self .allowed_roots
218+ )
217219
218220 if not full_path .is_file ():
219221 logger .error (ls .EDITOR_FILE_NOT_FOUND .format (path = file_path ))
@@ -251,7 +253,7 @@ def replace_code_block(
251253 logger .success (ls .TOOL_FILE_EDIT_SURGICAL_SUCCESS .format (path = file_path ))
252254 return True
253255
254- except ValueError :
256+ except PermissionError :
255257 logger .error (ls .FILE_OUTSIDE_ROOT .format (action = cs .FileAction .EDIT ))
256258 return False
257259 except Exception as e :
You can’t perform that action at this time.
0 commit comments