Browse Source

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 years ago
parent
commit
50e429fb5c
1 changed files with 2 additions and 1 deletions
  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)