Do not allow to upload SVG logos with embedded raster images in them

Those are for example png or jpg images. They do not render properly.
This commit is contained in:
Pea Tyczynska
2020-03-04 14:25:14 +00:00
parent beb3c5b00d
commit 44519fcf8e
3 changed files with 46 additions and 2 deletions

View File

@@ -80,6 +80,16 @@ class NoCommasInPlaceHolders:
raise ValidationError(self.message)
class NoEmbeddedImagesInSVG:
def __init__(self, message='This SVG has an embedded raster image in it and will not render well'):
self.message = message
def __call__(self, form, field):
if '<image' in field.data.stream.read().decode("utf-8"):
raise ValidationError(self.message)
class OnlySMSCharacters:
def __call__(self, form, field):
non_sms_characters = sorted(list(SanitiseSMS.get_non_compatible_characters(field.data)))