Fix rm not accepting absolute paths
rm always glued its argument onto the player's current directory, so typing an absolute path (e.g. sudo rm /var/arrest/handle.sh) built a garbage path that matched no file and was rejected as "not allowed" - even with full rm/sudo rights. cd already special-cased a leading '/' as absolute; rm now does the same. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -240,7 +240,9 @@ class GameResponseService
|
||||
}
|
||||
|
||||
$filename = $messagePart[1];
|
||||
$fullPath = ($pwd === '/' ? '' : $pwd) . '/' . $filename;
|
||||
$fullPath = str_starts_with($filename, '/')
|
||||
? $filename
|
||||
: ($pwd === '/' ? '' : $pwd) . '/' . $filename;
|
||||
|
||||
if(!$this->isAllowedToRemove($fullPath, $player, $sudo))
|
||||
return ['result' => ['You are not allowed to remove this file.']];
|
||||
|
||||
Reference in New Issue
Block a user