From 934a271322f360ceaacb07bc8189272faa1d87b1 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 31 Jan 2018 10:38:44 +0000 Subject: [PATCH] Allow full stops in SMS senders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have a team who want their (short) web address as the text message sender. This commit updates the validation of text message senders to allow `.` as a valid character, which is currently blocking them from doing this. We can be fairly confident this works because: - the team are sending large volumes of messages already with their existing provider - we’ve tested it with all combinations of - both our text message providers - an Android phone and n iPhone --- app/main/forms.py | 4 ++-- app/main/validators.py | 4 ++-- tests/app/main/views/test_service_settings.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index ba7dd619a..48f39cbab 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -35,7 +35,7 @@ from app.main.validators import ( ValidGovEmail, NoCommasInPlaceHolders, OnlyGSMCharacters, - LettersAndNumbersOnly, + LettersNumbersAndFullStopsOnly, ) @@ -560,7 +560,7 @@ class ServiceSmsSenderForm(StripWhitespaceForm): validators=[ DataRequired(message="Can’t be empty"), Length(max=11, message="Enter 11 characters or fewer"), - LettersAndNumbersOnly(), + LettersNumbersAndFullStopsOnly(), ] ) is_default = BooleanField("Make this text message sender the default") diff --git a/app/main/validators.py b/app/main/validators.py index d7bee1af4..92074b1d6 100644 --- a/app/main/validators.py +++ b/app/main/validators.py @@ -66,9 +66,9 @@ class OnlyGSMCharacters: ) -class LettersAndNumbersOnly: +class LettersNumbersAndFullStopsOnly: - 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 diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 3178cdbd9..efd719c0f 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -814,7 +814,7 @@ def test_incorrect_letter_contact_block_input( ('', 'Can’t be empty'), ('abcdefghijkhgkg', 'Enter 11 characters or fewer'), (' ¯\_(ツ)_/¯ ', 'Use letters and numbers only'), - ('blood.co.uk', 'Use letters and numbers only'), + ('blood.co.uk', None), ]) def test_incorrect_sms_sender_input( sms_sender_input,