Merge pull request #10416 from appwrite/pla-3448

chore: update exception thrown when svg sanitization fails
This commit is contained in:
Jake Barnby 2025-09-01 20:16:41 +12:00 committed by GitHub
commit b6fddfc84a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View file

@ -435,6 +435,11 @@ return [
'description' => 'The requested favicon could not be found.',
'code' => 404,
],
Exception::AVATAR_SVG_SANITIZATION_FAILED => [
'name' => Exception::AVATAR_SVG_SANITIZATION_FAILED,
'description' => 'SVG sanitization failed.',
'code' => 400,
],
/** Storage */
Exception::STORAGE_FILE_ALREADY_EXISTS => [

View file

@ -474,7 +474,7 @@ App::get('/v1/avatars/favicon')
$sanitizer->minify(true);
$cleanSvg = $sanitizer->sanitize($data);
if ($cleanSvg === false) {
throw new \Exception('SVG sanitization failed');
throw new Exception(Exception::AVATAR_SVG_SANITIZATION_FAILED);
}
$response
->addHeader('Cache-Control', 'private, max-age=2592000') // 30 days

View file

@ -134,6 +134,7 @@ class Exception extends \Exception
public const AVATAR_IMAGE_NOT_FOUND = 'avatar_image_not_found';
public const AVATAR_REMOTE_URL_FAILED = 'avatar_remote_url_failed';
public const AVATAR_ICON_NOT_FOUND = 'avatar_icon_not_found';
public const AVATAR_SVG_SANITIZATION_FAILED = 'avatar_svg_sanitization_failed';
/** Storage */
public const STORAGE_FILE_ALREADY_EXISTS = 'storage_file_already_exists';