diff --git a/pyproject.toml b/pyproject.toml index 9260894..221aec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "smtpfast" -version = "0.1.0" +version = "0.1.1" description = "The official Python SDK for the SMTPfast API." readme = "README.md" license = "MIT" diff --git a/src/smtpfast/_core.py b/src/smtpfast/_core.py index 581932b..11aeab1 100644 --- a/src/smtpfast/_core.py +++ b/src/smtpfast/_core.py @@ -188,6 +188,9 @@ def __init__(self, core: AsyncCore) -> None: def _fill(route: str, values: Mapping[str, str] | None) -> str: for name, value in (values or {}).items(): + # "", "." or ".." would become a dot-segment that resolves to another endpoint. + if str(value) in ("", ".", ".."): + raise SMTPfastError(f"Invalid path parameter {name}: {str(value)!r}") route = route.replace("{" + name + "}", quote(str(value), safe="")) return route diff --git a/src/smtpfast/_version.py b/src/smtpfast/_version.py index 3dc1f76..485f44a 100644 --- a/src/smtpfast/_version.py +++ b/src/smtpfast/_version.py @@ -1 +1 @@ -__version__ = "0.1.0" +__version__ = "0.1.1" diff --git a/tests/test_client.py b/tests/test_client.py index d4b8ca4..5976168 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -31,6 +31,14 @@ def test_path_params_are_encoded(): assert rec.calls[0].url.raw_path.decode() == "/api/v1/inboxes/in%201/threads/th_2/emails/em%2F3/reply" +def test_empty_or_dot_path_params_are_rejected(): + client, rec = make() + for bad in ("", ".", ".."): + with pytest.raises(smtpfast.SMTPfastError): + client.emails.get(bad) + assert rec.calls == [] + + def test_query_params_skip_none_and_format_bools(): client, rec = make([ok({"data": [], "has_more": False})]) client.contacts.list(limit=5, disposable=False)