Stop passing bytes when dumping JSON (#7799)

This commit is contained in:
Patrick Cloke 2020-07-08 07:14:56 -04:00 committed by GitHub
parent e0c0129693
commit ff0680f69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 6 deletions

1
changelog.d/7799.misc Normal file
View File

@ -0,0 +1 @@
Ensure that strings (not bytes) are passed into JSON serialization.

View File

@ -251,10 +251,10 @@ class IdentityHandler(BaseHandler):
# 'browser-like' HTTPS. # 'browser-like' HTTPS.
auth_headers = self.federation_http_client.build_auth_headers( auth_headers = self.federation_http_client.build_auth_headers(
destination=None, destination=None,
method="POST", method=b"POST",
url_bytes=url_bytes, url_bytes=url_bytes,
content=content, content=content,
destination_is=id_server, destination_is=id_server.encode("ascii"),
) )
headers = {b"Authorization": auth_headers} headers = {b"Authorization": auth_headers}

View File

@ -562,13 +562,17 @@ class MatrixFederationHttpClient(object):
Returns: Returns:
list[bytes]: a list of headers to be added as "Authorization:" headers list[bytes]: a list of headers to be added as "Authorization:" headers
""" """
request = {"method": method, "uri": url_bytes, "origin": self.server_name} request = {
"method": method.decode("ascii"),
"uri": url_bytes.decode("ascii"),
"origin": self.server_name,
}
if destination is not None: if destination is not None:
request["destination"] = destination request["destination"] = destination.decode("ascii")
if destination_is is not None: if destination_is is not None:
request["destination_is"] = destination_is request["destination_is"] = destination_is.decode("ascii")
if content is not None: if content is not None:
request["content"] = content request["content"] = content

View File

@ -50,7 +50,7 @@ class VoipRestServlet(RestServlet):
# We need to use standard padded base64 encoding here # We need to use standard padded base64 encoding here
# encode_base64 because we need to add the standard padding to get the # encode_base64 because we need to add the standard padding to get the
# same result as the TURN server. # same result as the TURN server.
password = base64.b64encode(mac.digest()) password = base64.b64encode(mac.digest()).decode("ascii")
elif turnUris and turnUsername and turnPassword and userLifetime: elif turnUris and turnUsername and turnPassword and userLifetime:
username = turnUsername username = turnUsername