Skip to content

Commit b33c236

Browse files
committed
fixing path bug in ReadFileTool
1 parent 662354a commit b33c236

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/google/adk/tools/environment/_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from __future__ import annotations
1818

1919
import logging
20+
import shlex
2021
from typing import Any
2122
from typing import Optional
2223
from typing import TYPE_CHECKING
@@ -187,7 +188,8 @@ async def run_async(
187188
sed_range = f'{start},{end_line}'
188189
else:
189190
sed_range = f'{start},$'
190-
cmd = f"cat -n '{path}' | sed -n '{sed_range}p'"
191+
safe_path = shlex.quote(path)
192+
cmd = f"cat -n {safe_path} | sed -n '{sed_range}p'"
191193
res = await self._environment.execute(cmd)
192194
if res.exit_code == 0:
193195
return {'status': 'ok', 'content': _truncate(res.stdout)}

0 commit comments

Comments
 (0)