Skip to content

Commit d119c76

Browse files
hive-botclaude
andcommitted
fix: URL-encode spoken-terms IDs in request paths
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 30fb0f4 commit d119c76

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎deepl/deepl_client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,8 +899,8 @@ def _spoken_terms_json(entries: SpokenTermsEntries) -> dict:
899899
@staticmethod
900900
def _spoken_terms_id(spoken_terms: Union[str, SpokenTerms]) -> str:
901901
if isinstance(spoken_terms, SpokenTerms):
902-
return spoken_terms.spoken_terms_id
903-
return spoken_terms
902+
spoken_terms = spoken_terms.spoken_terms_id
903+
return urllib.parse.quote(spoken_terms, safe="")
904904

905905
def get_languages_for_resource(
906906
self,

‎tests/offline/test_spoken_terms.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,9 @@ def test_rejects_a_term_with_a_newline_without_sending_a_request(mocked):
6565
make_deepl_client().create_spoken_terms(
6666
"terms", [deepl.SpokenTermsEntries("en", ["a\nb"])]
6767
)
68+
69+
70+
def test_url_encodes_the_id_in_the_path(mocked):
71+
mocked.delete(url("v3/spoken-terms/a%2Fb%3Fc"), status=204)
72+
73+
make_deepl_client().delete_spoken_terms("a/b?c")

0 commit comments

Comments
 (0)