Skip to content

Commit 14def4f

Browse files
committed
Use a guaranteed invalid email in sanitize_email
TLD `.invalid` is quaranteed to be invalid by IETF RFC2606 hence it is safer than earlier `sanitized.net`, that could, in theory, have e.g. a working mail server.
1 parent 742bc1f commit 14def4f

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

database_sanitizer/sanitizers/user.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def sanitize_email(value):
1212
given_name = given_names[num1 % given_names_count]
1313
surname = surnames[num2 % surnames_count]
1414
case_convert = (text_type.lower if num3 % 8 > 0 else lambda x: x)
15-
return '{first}.{last}@x{num:x}.sanitized.net'.format(
15+
return '{first}.{last}@x{num:x}.san.example.com'.format(
1616
first=case_convert(given_name),
1717
last=case_convert(surname).replace("'", ''),
1818
num=num3)

database_sanitizer/tests/test_sanitizers_user.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ def setup_module():
99
def test_sanitize_email():
1010
assert user.sanitize_email(None) is None
1111
assert user.sanitize_email('') == ''
12-
assert user.sanitize_email('test@example.com') == (
13-
'zoe.burke@xce13103b.sanitized.net')
14-
assert user.sanitize_email('test2@example.com') == (
15-
'Melanie.Pratt@x4feb7f40.sanitized.net')
16-
assert user.sanitize_email('test@example.com') == (
17-
'zoe.burke@xce13103b.sanitized.net')
18-
assert user.sanitize_email('test3@example.com') == (
19-
'irene.archer@x3d2e92ec.sanitized.net')
20-
assert user.sanitize_email(' test3@example.com ') == (
21-
'irene.archer@x3d2e92ec.sanitized.net')
12+
assert user.sanitize_email('test<@example.net') == (
13+
'zoe.burke@xce13103b.san.example.com')
14+
assert user.sanitize_email('test2@example.net') == (
15+
'Melanie.Pratt@x4feb7f40.san.example.com')
16+
assert user.sanitize_email('test@example.net') == (
17+
'zoe.burke@xce13103b.san.example.com')
18+
assert user.sanitize_email('test3@example.net') == (
19+
'irene.archer@x3d2e92ec.san.example.com')
20+
assert user.sanitize_email(' test3@example.net ') == (
21+
'irene.archer@x3d2e92ec.san.example.com')
2222

2323

2424
def test_sanitize_username():
@@ -59,9 +59,9 @@ def test_sanitize_surname_en_gb():
5959

6060

6161
def test_sanitize_email_resets_on_session_reset():
62-
assert user.sanitize_email('test@example.com') == (
63-
'zoe.burke@xce13103b.sanitized.net')
62+
assert user.sanitize_email('test@example.net') == (
63+
'zoe.burke@xce13103b.san.example.com')
6464
session.reset()
65-
assert user.sanitize_email('test@example.com') != (
66-
'zoe.burke@xce13103b.sanitized.net')
65+
assert user.sanitize_email('test@example.net') != (
66+
'zoe.burke@xce13103b.san.example.com')
6767
session.reset(b'not-so-secret-key')

0 commit comments

Comments
 (0)