mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-25 00:33:58 -04:00
Merge pull request #2037 from alphagov/strip-obscure-whitespace
Strip obscure whitespace from form submissions
This commit is contained in:
32
tests/app/main/test_strip_whitespace_form.py
Normal file
32
tests/app/main/test_strip_whitespace_form.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
from wtforms import Form, StringField
|
||||
|
||||
from app.main.forms import StripWhitespaceForm, StripWhitespaceStringField
|
||||
|
||||
|
||||
class ExampleForm(StripWhitespaceForm):
|
||||
foo = StringField('Foo')
|
||||
|
||||
|
||||
class ExampleFormSpecialField(Form):
|
||||
foo = StripWhitespaceStringField('foo')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('submitted_data', [
|
||||
'bar',
|
||||
' bar ',
|
||||
"""
|
||||
\t bar
|
||||
""",
|
||||
' \u180E\u200B \u200C bar \u200D \u2060\uFEFF ',
|
||||
])
|
||||
@pytest.mark.parametrize('form', [
|
||||
ExampleForm,
|
||||
ExampleFormSpecialField,
|
||||
])
|
||||
def test_form_strips_all_whitespace(
|
||||
app_,
|
||||
form,
|
||||
submitted_data,
|
||||
):
|
||||
assert form(foo=submitted_data).foo.data == 'bar'
|
||||
Reference in New Issue
Block a user