Additional error checking for scratchpads

This commit is contained in:
2026-01-09 09:37:21 +01:00
parent 15cfa01114
commit 6328523624
5 changed files with 39 additions and 5 deletions

View File

@@ -70,8 +70,17 @@ try {
if ($cmd === 'load') {
$text = '';
if (@is_file($resolved) && @is_readable($resolved)) {
$text = (string)io_readFile($resolved, false);
$exists = @is_file($resolved);
if ($exists) {
if (!@is_readable($resolved)) {
luxtools_scratchpad_json(500, ['ok' => false, 'error' => 'unreadable']);
}
$read = io_readFile($resolved, false);
if ($read === false) {
luxtools_scratchpad_json(500, ['ok' => false, 'error' => 'unreadable']);
}
$text = (string)$read;
}
luxtools_scratchpad_json(200, ['ok' => true, 'text' => $text]);
}