D1112: hgweb: fix decodevaluefromheaders to always return a bytes value
durin42 (Augie Fackler)
phabricator at mercurial-scm.org
Mon Oct 16 11:10:34 EDT 2017
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
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)
To: durin42, #hg-reviewers, yuja
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list