Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ In Development
* Python 3.8 and 3.9 are no longer supported.
* The `original` field of the returned validated email object incorrectly un-escaped the local part of the email address. Now it returns the original address, without any display name, as passed to validate_email.
* add support python3.15
* The command-line tool now reads `0`, `false`, `no` and `off` in its environment variables (e.g. `CHECK_DELIVERABILITY=0`) as false. Previously any non-empty value turned the option on.
* The IPv6 tag of a domain literal is now case-insensitive, as in the RFCs, so `me@[ipv6:::1]` is accepted (and normalized to `me@[IPv6:::1]`) when `allow_domain_literal=True`.

2.3.0 (August 26, 2025)
Expand Down
3 changes: 2 additions & 1 deletion email_validator/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def main(dns_resolver: Optional[_Resolver] = None) -> None:
'ALLOW_DISPLAY_NAME',
'GLOBALLY_DELIVERABLE', 'CHECK_DELIVERABILITY', 'TEST_ENVIRONMENT'):
if varname in os.environ:
options[varname.lower()] = bool(os.environ[varname])
# Any non-empty string is truthy, so the usual false values are recognized explicitly.
options[varname.lower()] = os.environ[varname].strip().lower() not in ('', '0', 'false', 'no', 'off')
for varname in ('DEFAULT_TIMEOUT',):
if varname in os.environ:
options[varname.lower()] = float(os.environ[varname])
Expand Down
13 changes: 13 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ def test_main_multi_input(monkeypatch: pytest.MonkeyPatch, capsys: pytest.Captur
assert test_cases[3] in stdout


@pytest.mark.parametrize(
('value', 'allowed'),
[('1', True), ('true', True), ('yes', True), ('0', False), ('false', False), ('FALSE', False), ('no', False), ('', False)]
)
def test_main_boolean_environment_variable(monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str],
value: str, allowed: bool) -> None:
monkeypatch.setenv('ALLOW_DOMAIN_LITERAL', value)
monkeypatch.setattr('sys.argv', ['email_validator', 'me@[127.0.0.1]'])
validator_command_line_tool(dns_resolver=RESOLVER)
stdout, _ = capsys.readouterr()
assert ('A bracketed IP address after the @-sign is not allowed here.' in stdout) is not allowed


def test_bytes_input() -> None:
input_email = b"testaddr@example.tld"
valid_email = validate_email(input_email, check_deliverability=False)
Expand Down
Loading