Skip to content

Commit 952c501

Browse files
committed
Improved regexp for email format to comfort test suite
1 parent 7f85877 commit 952c501

File tree

6 files changed

+2
-5
lines changed

6 files changed

+2
-5
lines changed

CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fixed detecting when infinity is reached with multipleOf
55
* Fixed that min/max items/lenght/properties can be float
66
* Fixed that everything with empty `not` is invalid
7+
* Improved regexp for email format to comfort test suite
78

89
=== 2.20.0 (2024-06-15)
910

fastjsonschema/draft04.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class CodeGeneratorDraft04(CodeGenerator):
2727
# library. Some regexps are not 100% precise but good enough, fast and without dependencies.
2828
FORMAT_REGEXS = {
2929
'date-time': r'^\d{4}-[01]\d-[0-3]\d(t|T)[0-2]\d:[0-5]\d:[0-5]\d(?:\.\d+)?(?:[+-][0-2]\d:[0-5]\d|[+-][0-2]\d[0-5]\d|z|Z)\Z',
30-
'email': r'^[^@]+@[^@]+\.[^@]+\Z',
30+
'email': r'^(?!.*\.\..*@)[^@.][^@]*(?<!\.)@[^@]+\.[^@]+\Z',
3131
'hostname': r'^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]{0,61}[A-Za-z0-9])\Z',
3232
'ipv4': r'^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\Z',
3333
'ipv6': r'^(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,4}:){5}(?:[0-9A-Fa-f]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4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,4}:){,6}[0-9A-Fa-f]{1,4})?::)\Z',

tests/json_schema/test_draft04.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def pytest_generate_tests(metafunc):
2020
'enum.json',
2121

2222
# TODO: fix formats
23-
'email.json',
2423
'date-time.json',
2524
'date.json',
2625
'ipv4.json',

tests/json_schema/test_draft06.py

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def pytest_generate_tests(metafunc):
2020
'enum.json',
2121

2222
# TODO: fix formats
23-
'email.json',
2423
'date-time.json',
2524
'date.json',
2625
'ipv4.json',

tests/json_schema/test_draft07.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def pytest_generate_tests(metafunc):
2222
'enum.json',
2323

2424
# TODO: fix formats
25-
'email.json',
2625
'date-time.json',
2726
'date.json',
2827
'ipv4.json',

tests/json_schema/test_draft2019.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def pytest_generate_tests(metafunc):
2222
'enum.json',
2323

2424
# TODO: fix formats
25-
'email.json',
2625
'date-time.json',
2726
'date.json',
2827
'ipv4.json',

0 commit comments

Comments
 (0)