Przeglądaj źródła

Ensure the name of the headers are always of the correct type

This comes with one twist, in python3 the lines we get from
subprocess are bytes but we don't want to convert them entirely
to unicode, we only want to convert the header's name, and
there using `str()` won't work, we need a full `.decode()`.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
Pierre-Yves Chibon 4 lat temu
rodzic
commit
50e429fb5c
1 zmienionych plików z 2 dodań i 1 usunięć
  1. 2 1
      pagure/ui/clone.py

+ 2 - 1
pagure/ui/clone.py

@@ -128,6 +128,7 @@ def proxy_raw_git():
             if not line:
                 break
             header = line.split(b": ", 1)
+            header[0] = header[0].decode("utf-8")
             headers[header[0].lower()] = header[1]
 
         if len(headers) == 0:
@@ -135,7 +136,7 @@ def proxy_raw_git():
 
         if "status" not in headers:
             # If no status provided, assume 200 OK as per RFC3875
-            headers["status"] = "200 OK"
+            headers[str("status")] = "200 OK"
 
         respcode, respmsg = headers.pop("status").split(" ", 1)
         wrapout = werkzeug.wsgi.wrap_file(flask.request.environ, out)