Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ce0a87b

Browse filesBrowse files
committed
Improve base64 decoding safety in byte responses
1 parent b69ff55 commit ce0a87b
Copy full SHA for ce0a87b

File tree

Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-3
lines changed

‎async_tls_client/__version__.py

Copy file name to clipboardExpand all lines: async_tls_client/__version__.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
__title__ = "async_tls_client"
88
__description__ = "Asyncio fork of Python-TLS-Client with updated dependencies"
9-
__version__ = "1.0.10"
9+
__version__ = "1.1"
1010
__author__ = "Diprog (fork), Florian Zager (original)"
1111
__license__ = "MIT"

‎async_tls_client/response.py

Copy file name to clipboardExpand all lines: async_tls_client/response.py
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,16 @@ def build_response(res: Union[dict, list], res_cookies: RequestsCookieJar) -> Re
7272
response.headers = response_headers
7373
# Add cookies
7474
response.cookies = res_cookies
75+
76+
# Decode the byte-response (base64 format)
77+
try:
78+
data_part = res["body"].split(',', 1)[1]
79+
except IndexError:
80+
import logging
81+
logging.warning("Invalid base64 response format")
82+
data_part = res["body"]
7583
# Add response body
76-
response.text = base64.b64decode(res["body"].split(',')[1]).decode(errors='ignore')
84+
response.text = base64.b64decode(data_part).decode(errors='ignore')
7785
# Add response content (bytes)
78-
response._content = base64.b64decode(res["body"].split(',')[1])
86+
response._content = base64.b64decode(data_part)
7987
return response

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.