Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,20 @@ def test_returns_failed_validation_on_domain_beyond_rfc_limits(value: str):
"value",
[
# IDNA 2003 maps these to "example.com"; see `_relies_on_idna_mapping`
"example.com", # fullwidth letters
"example.com",
"example.ⅽom", # small roman numeral one hundred
"Kelvin.com", # Kelvin sign
"ſhop.com", # long s
"example.\uff43\uff4f\uff4d", # fullwidth letters
"\uff45\uff58\uff41\uff4d\uff50\uff4c\uff45.com",
"example.\u217dom", # small roman numeral one hundred
"\u212aelvin.com", # Kelvin sign
"\u017fhop.com", # long s
"example。com", # ideographic full stop
"example.com", # fullwidth full stop
"example。com", # halfwidth ideographic full stop
"exam­ple.com", # soft hyphen
"example.co​m", # zero width space
"exa‍mple.com", # zero width joiner
"exam️ple.com", # variation selector
"examp⁠le.com", # word joiner
"example.com", # zero width no-break space
"example\uff0ecom", # fullwidth full stop
"example\uff61com", # halfwidth ideographic full stop
"exam\u00adple.com", # soft hyphen
"example.co\u200bm", # zero width space
"exa\u200dmple.com", # zero width joiner
"exam\ufe0fple.com", # variation selector
"examp\u2060le.com", # word joiner
"\ufeffexample.com", # zero width no-break space
"exämple.com".replace("ä", "ä"), # not NFC
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_rejects_newline_after_local_part(local_part: str):
assert isinstance(email(f"{local_part}\n@example.com"), ValidationError)


@pytest.mark.parametrize("domain_part", ["example.com", "exam­ple.com"])
@pytest.mark.parametrize("domain_part", ["example.\uff43\uff4f\uff4d", "exam\u00adple.com"])
def test_returns_failed_validation_on_idna_mapped_lookalike_domain(domain_part: str):
"""Test returns failed validation on email domains that only IDNA 2003 mapping makes valid."""
assert isinstance(email(f"user@{domain_part}"), ValidationError)
6 changes: 4 additions & 2 deletions tests/test_hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,15 @@ def test_rejects_trailing_newline_in_hostnames_and_ports(value: str):
assert isinstance(hostname(value), ValidationError)


@pytest.mark.parametrize("value", ["ſerver", "Kelvin", "ıntranet", "İntranet:8080"])
@pytest.mark.parametrize(
"value", ["\u017ferver", "\u212aelvin", "\u0131ntranet", "\u0130ntranet:8080"]
)
def test_returns_failed_validation_on_non_ascii_simple_hostname(value: str):
"""Test returns failed validation on non-ASCII case equivalents in simple hostnames."""
assert isinstance(hostname(value), ValidationError)


@pytest.mark.parametrize("value", ["example.com", "exam­ple.com:443"])
@pytest.mark.parametrize("value", ["example.\uff43\uff4f\uff4d", "exam\u00adple.com:443"])
def test_returns_failed_validation_on_idna_mapped_lookalike_hostname(value: str):
"""Test returns failed validation on hostnames that only IDNA 2003 mapping makes valid."""
assert isinstance(hostname(value), ValidationError)
2 changes: 1 addition & 1 deletion tests/test_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ def test_url_accepts_percent_encoded_controls(encoded: str, template: str):

@pytest.mark.parametrize(
"value",
["https://example.com/", "https://exam­ple.com/", "http://ſerver/"],
["https://example.\uff43\uff4f\uff4d/", "https://exam\u00adple.com/", "http://\u017ferver/"],
)
def test_returns_failed_validation_on_idna_mapped_lookalike_url(value: str):
"""Test returns failed validation on url hosts that only IDNA 2003 mapping makes valid."""
Expand Down
Loading