Percent-encode colons in URL query values for AsyncClient.request
authorHarmon <Harmon758@gmail.com>
Wed, 18 May 2022 10:33:56 +0000 (05:33 -0500)
committerHarmon <Harmon758@gmail.com>
Wed, 18 May 2022 10:34:51 +0000 (05:34 -0500)
tweepy/asynchronous/client.py

index f03883a195efa5d82a1d06f7aa11f4a201a5762d..3bef8f98679123dc7f9f8fde88f8212993ee70d3 100644 (file)
@@ -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}"