From: Harmon Date: Wed, 18 May 2022 10:33:56 +0000 (-0500) Subject: Percent-encode colons in URL query values for AsyncClient.request X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fa73d7059d97aaffd318e8cc59da739bb0ad9b68;p=tweepy.git Percent-encode colons in URL query values for AsyncClient.request --- diff --git a/tweepy/asynchronous/client.py b/tweepy/asynchronous/client.py index f03883a..3bef8f9 100644 --- a/tweepy/asynchronous/client.py +++ b/tweepy/asynchronous/client.py @@ -75,6 +75,14 @@ class AsyncBaseClient(BaseClient): url, headers, body = oauth_client.sign( url, method, headers=headers ) + # oauthlib.oauth1.Client (OAuthClient) expects colons in query + # values (e.g. in timestamps) to be percent-encoded, while + # aiohttp.ClientSession does not automatically encode them + before_query, question_mark, query = url.partition('?') + url = URL( + f"{before_query}?{query.replace(':', '%3A')}", + encoded = True + ) params = None else: headers["Authorization"] = f"Bearer {self.bearer_token}"