agent foundation

This commit is contained in:
2026-03-06 00:44:52 +01:00
parent 9819cba733
commit 9a08f96c11
199 changed files with 8522 additions and 1880 deletions

View File

@@ -101,6 +101,7 @@ class UserAvatarService
if (!$ext) {
return ['ok' => false, 'error' => t('Invalid image file')];
}
// SVG can contain JavaScript — reject files that don't pass the safety check.
if ($isSvg && !self::imageIsSafeSvg($tmpPath)) {
return ['ok' => false, 'error' => t('Invalid image file')];
}
@@ -117,6 +118,7 @@ class UserAvatarService
}
@chmod($originalPath, 0644);
// Prefer WebP for variants (better compression); fall back to JPEG if GD lacks WebP support.
$variantExt = function_exists('imagewebp') ? 'webp' : 'jpg';
if (!$isSvg && self::imageCanResize()) {
foreach (self::SIZES as $size) {
@@ -172,6 +174,7 @@ class UserAvatarService
$this->delete($uuid);
$originalPath = $dir . '/original.' . $ext;
// rename() fails across filesystem boundaries (e.g. /tmp → app storage), fall back to copy.
if (!@rename($tmpPath, $originalPath)) {
if (!@copy($tmpPath, $originalPath)) {
@unlink($tmpPath);