refac
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
# Known static asset paths used as default profile images
|
||||
_ALLOWED_STATIC_PATHS = (
|
||||
"/user.png",
|
||||
"/static/favicon.png",
|
||||
'/user.png',
|
||||
'/static/favicon.png',
|
||||
)
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ def validate_profile_image_url(url: str) -> str:
|
||||
return url
|
||||
|
||||
_ALLOWED_DATA_PREFIXES = (
|
||||
"data:image/png",
|
||||
"data:image/jpeg",
|
||||
"data:image/gif",
|
||||
"data:image/webp",
|
||||
'data:image/png',
|
||||
'data:image/jpeg',
|
||||
'data:image/gif',
|
||||
'data:image/webp',
|
||||
)
|
||||
if any(url.startswith(prefix) for prefix in _ALLOWED_DATA_PREFIXES):
|
||||
return url
|
||||
@@ -33,6 +33,4 @@ def validate_profile_image_url(url: str) -> str:
|
||||
if url in _ALLOWED_STATIC_PATHS:
|
||||
return url
|
||||
|
||||
raise ValueError(
|
||||
"Invalid profile image URL: only data URIs and default avatars are allowed."
|
||||
)
|
||||
raise ValueError('Invalid profile image URL: only data URIs and default avatars are allowed.')
|
||||
|
||||
Reference in New Issue
Block a user