[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [bridgedb/develop] Turn HTTP arguments dict from bytes to str.



commit 29c2bd17c43fb5ab541281e7a9d2822fc0045338
Author: Philipp Winter <phw@xxxxxxxxx>
Date:   Thu Jan 30 15:28:06 2020 -0800

    Turn HTTP arguments dict from bytes to str.
---
 bridgedb/distributors/https/server.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bridgedb/distributors/https/server.py b/bridgedb/distributors/https/server.py
index 2d230b9..52a083f 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -974,6 +974,14 @@ class BridgesResource(CustomErrorHandlingResource, CSPResource):
         logging.info("Replying to web request from %s. Parameters were %r"
                      % (ip, request.args))
 
+        # Convert all key/value pairs from bytes to str.
+        str_args = {}
+        for arg, values in request.args.items():
+            arg = arg if isinstance(arg, str) else arg.decode("utf-8")
+            values = [value.decode("utf-8") if isinstance(value, bytes) else value for value in values]
+            str_args[arg] = values
+        request.args = str_args
+
         if ip:
             bridgeRequest = HTTPSBridgeRequest()
             bridgeRequest.client = ip



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits