mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Merge pull request #2037 from alphagov/strip-obscure-whitespace
Strip obscure whitespace from form submissions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import string
|
||||
import weakref
|
||||
from datetime import datetime, timedelta
|
||||
from itertools import chain
|
||||
@@ -40,6 +41,15 @@ from app.main.validators import (
|
||||
ValidGovEmail,
|
||||
)
|
||||
|
||||
OBSCURE_WHITESPACE = (
|
||||
'\u180E' # Mongolian vowel separator
|
||||
'\u200B' # zero width space
|
||||
'\u200C' # zero width non-joiner
|
||||
'\u200D' # zero width joiner
|
||||
'\u2060' # word joiner
|
||||
'\uFEFF' # zero width non-breaking space
|
||||
)
|
||||
|
||||
|
||||
def get_time_value_and_label(future_time):
|
||||
return (
|
||||
@@ -110,7 +120,7 @@ def email_address(label='Email address', gov_user=True):
|
||||
|
||||
def strip_whitespace(value):
|
||||
if value is not None and hasattr(value, 'strip'):
|
||||
return value.strip()
|
||||
return value.strip(string.whitespace + OBSCURE_WHITESPACE)
|
||||
return value
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user