Skip to content

Commit 8cc919c

Browse files
author
derwentx
committed
Hardening encoding in post-mortem
1 parent 97ed070 commit 8cc919c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

wordpress/api.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,16 @@ def request_post_mortem(self, response=None):
169169
if header_api_url:
170170
header_api_url = StrUtils.eviscerate(header_api_url, '/')
171171

172-
if header_api_url and requester_api_url\
173-
and header_api_url != requester_api_url:
174-
reason = "hostname mismatch. %s != %s" % (
175-
header_api_url, requester_api_url
176-
)
172+
if (
173+
header_api_url and requester_api_url
174+
and StrUtils.to_text(header_api_url)
175+
!= StrUtils.to_text(requester_api_url)
176+
):
177+
reason = "hostname mismatch. %s != %s" % tuple(map(
178+
StrUtils.to_text, [
179+
header_api_url, requester_api_url
180+
]
181+
))
177182
header_url = StrUtils.eviscerate(header_api_url, '/')
178183
header_url = StrUtils.eviscerate(
179184
header_url, self.requester.api)
@@ -188,7 +193,7 @@ def request_post_mortem(self, response=None):
188193
response.status_code,
189194
UrlUtils.beautify_response(response),
190195
response_headers,
191-
request_body[:1000]
196+
StrUtils.to_binary(request_body)[:1000]
192197
]))
193198
if reason:
194199
msg += "\nBecause of %s" % StrUtils.to_binary(reason)

0 commit comments

Comments
 (0)