fix(pets): adds file ext validation on the server side

This commit is contained in:
2024-12-10 17:48:29 -03:00
parent 24c01ff2bb
commit 4c5cdfb13d
2 changed files with 14 additions and 4 deletions

View File

@@ -1,6 +1,5 @@
import re
from typing import Optional
class Validators:
@staticmethod
@@ -17,4 +16,10 @@ class Validators:
float(value)
return True
except:
return False
return False
@staticmethod
def allowed_file_img(filename):
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'webp'}
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS