pÃrevent storing files/folder with filenames exceeding their max name length

This commit is contained in:
Mario
2025-04-16 11:03:08 +00:00
parent d2aad8a41a
commit 4c962417ff
5 changed files with 54 additions and 20 deletions

View File

@@ -796,6 +796,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
}
}
if (strlen($filename) > MAX_FILENAME_LENGTH) {
logger('filename too long');
$ret['message'] = t('Filename too long');
return $ret;
}
if(! $hash)
$hash = new_uuid();
@@ -1185,6 +1191,12 @@ function attach_mkdir($channel, $observer_hash, $arr = null) {
return $ret;
}
if(strlen($arr['filename']) > MAX_FOLDER_LENGTH) {
logger('pathname too long');
$ret['message'] = t('Pathname too long');
return $ret;
}
$arr['hash'] = $arr['hash'] ?? new_uuid();
// Check for duplicate name.
@@ -2589,6 +2601,11 @@ function attach_move($channel_id, $resource_id, $new_folder_hash, $newname = '',
}
}
if (strlen($filename) > MAX_FILENAME_LENGTH) {
logger('filename too long');
$ret['message'] = t('Filename too long');
return $ret;
}
q("update attach set content = '%s', folder = '%s', filename = '%s', edited = '%s' where id = %d",
dbescbin($newstorepath),