Allow straight single quote in sms sender names

This is so we can allow the sender name 'UC' for DWP.

Note, this is specifically only straight single quotes and not curly
quotes or double quotes. Curly quotes are not supported in the GSM
character set (https://en.wikipedia.org/wiki/GSM_03.38). There is
currently no defined user ask to support double quotes in sms sender
names.

I have tested this by sending a message through both Firetext and MMG to
make sure they both support the single quote character in SMS sender
names.

DWP also have had no particular issues using the SMS sender name with
their existing system in the past either.
This commit is contained in:
David McDonald
2021-07-26 15:10:57 +01:00
parent 65bdc7f5a4
commit a6cac27957
3 changed files with 5 additions and 4 deletions

View File

@@ -45,7 +45,7 @@ from app.main.validators import (
CommonlyUsedPassword,
CsvFileValidator,
DoesNotStartWithDoubleZero,
LettersNumbersFullStopsAndUnderscoresOnly,
LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly,
MustContainAlphanumericCharacters,
NoCommasInPlaceHolders,
NoEmbeddedImagesInSVG,
@@ -1734,7 +1734,7 @@ class ServiceSmsSenderForm(StripWhitespaceForm):
DataRequired(message="Cannot be empty"),
Length(max=11, message="Enter 11 characters or fewer"),
Length(min=3, message="Enter 3 characters or more"),
LettersNumbersFullStopsAndUnderscoresOnly(),
LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly(),
DoesNotStartWithDoubleZero(),
]
)

View File

@@ -144,9 +144,9 @@ class BroadcastLength:
)
class LettersNumbersFullStopsAndUnderscoresOnly:
class LettersNumbersSingleQuotesFullStopsAndUnderscoresOnly:
regex = re.compile(r'^[a-zA-Z0-9\s\._]+$')
regex = re.compile(r"^[a-zA-Z0-9\s\._']+$")
def __init__(self, message='Use letters and numbers only'):
self.message = message

View File

@@ -199,6 +199,7 @@ def test_if_string_contains_alphanumeric_characters_does_not_raise(string):
('00111222333', True, 'Cannot start with 00'),
('UK_GOV', False, None), # Underscores are allowed
('UK.GOV', False, None), # Full stops are allowed
("'UC'", False, None), # Straight single quotes are allowed
]
)
def test_sms_sender_form_validation(