diff --git a/app/main/forms.py b/app/main/forms.py index 4b1deece3..fd0e85f50 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -53,6 +53,7 @@ from app.main.validators import ( NoCommasInPlaceHolders, NoEmbeddedImagesInSVG, NoPlaceholders, + NoTextInSVG, OnlySMSCharacters, ValidEmail, ValidGovEmail, @@ -1884,7 +1885,8 @@ class SVGFileUpload(StripWhitespaceForm): validators=[ FileAllowed(['svg'], 'SVG Images only!'), DataRequired(message="You need to upload a file to submit"), - NoEmbeddedImagesInSVG() + NoEmbeddedImagesInSVG(), + NoTextInSVG(), ] ) diff --git a/app/main/validators.py b/app/main/validators.py index cda57b3a5..949c1e941 100644 --- a/app/main/validators.py +++ b/app/main/validators.py @@ -102,6 +102,11 @@ class NoEmbeddedImagesInSVG(NoElementInSVG): message = 'This SVG has an embedded raster image in it and will not render well' +class NoTextInSVG(NoElementInSVG): + element = 'text' + message = 'This SVG has text which has not been converted to paths and may not render well' + + class OnlySMSCharacters: def __init__(self, *args, template_type, **kwargs): diff --git a/tests/app/main/views/test_letter_branding.py b/tests/app/main/views/test_letter_branding.py index 4a5bdcbe6..3c150222e 100644 --- a/tests/app/main/views/test_letter_branding.py +++ b/tests/app/main/views/test_letter_branding.py @@ -357,6 +357,14 @@ def test_create_letter_branding_when_uploading_valid_file( ''', 'This SVG has an embedded raster image in it and will not render well', ), + ( + ''' + + Will render differently depending on fonts installed + + ''', + 'This SVG has text which has not been converted to paths and may not render well', + ), )) def test_create_letter_branding_fails_validation_when_uploading_SVG_with_bad_element( mocker,