mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-10 08:52:21 +02:00
fix(tools): refuse an empty write_file body that would truncate a file
The handler opened the target in "w" mode without looking at the body, so a call whose content section was lost by a parser cut the file to 0 bytes and still answered exit_code=0 (#6414). Gate the truncating open on the size the file has on disk — the read just above it answers "" for bytes it cannot decode, so an undecodable target would otherwise look empty — and let only an inline-JSON content key that is literally an empty string declare the clear. Also stop turning a null content into the four characters "None", which could be neither refused as a lost body nor honoured as an empty write.
This commit is contained in:
+3
-1
@@ -609,7 +609,9 @@ Read a file and return its contents.""",
|
||||
<file path>
|
||||
<file contents>
|
||||
```
|
||||
Write content to a file. First line is the path, rest is the content.""",
|
||||
Write content to a file. First line is the path, rest is the content. An empty body is
|
||||
refused when the target already holds data — to clear a file on purpose, send
|
||||
`{"path": "<file path>", "content": ""}` instead.""",
|
||||
|
||||
"edit_file": """\
|
||||
```edit_file
|
||||
|
||||
Reference in New Issue
Block a user