# HG changeset patch # User Augie Fackler # Date 2017-10-15 04:43:01 # Node ID 0a2ef612ad50e3f9e5700178c2df08c29228e511 # Parent dc2bf70741472fe5f6a5662a84036821fcbda92d hgweb: fix decodevaluefromheaders to always return a bytes value That's more in line with what we want, and we know it's ASCII data since that's all HTTP technically allows in headers anyway. Differential Revision: https://phab.mercurial-scm.org/D1112 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 @@ HGTYPE2 = 'application/mercurial-0.2' 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)