Patchwork D1112: hgweb: fix decodevaluefromheaders to always return a bytes value

login
register
mail settings
Submitter phabricator
Date Oct. 16, 2017, 3:10 p.m.
Message ID <04758edb9cd98a5843351b98ec9cf5db@localhost.localdomain>
Download mbox | patch
Permalink /patch/24998/
State Not Applicable
Headers show

Comments

phabricator - Oct. 16, 2017, 3:10 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0a2ef612ad50: hgweb: fix decodevaluefromheaders to always return a bytes value (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1112?vs=2814&id=2820

REVISION DETAIL
  https://phab.mercurial-scm.org/D1112

AFFECTED FILES
  mercurial/hgweb/protocol.py

CHANGE DETAILS




To: durin42, #hg-reviewers, yuja
Cc: mercurial-devel

Patch

diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -30,15 +30,18 @@ 
 HGERRTYPE = 'application/hg-error'
 
 def decodevaluefromheaders(req, headerprefix):
-    """Decode a long value from multiple HTTP request headers."""
+    """Decode a long value from multiple HTTP request headers.
+
+    Returns the value as a bytes, not a str.
+    """
     chunks = []
     i = 1
+    prefix = headerprefix.upper().replace(r'-', r'_')
     while True:
-        v = req.env.get('HTTP_%s_%d' % (
-            headerprefix.upper().replace('-', '_'), i))
+        v = req.env.get(r'HTTP_%s_%d' % (prefix, i))
         if v is None:
             break
-        chunks.append(v)
+        chunks.append(pycompat.bytesurl(v))
         i += 1
 
     return ''.join(chunks)