diff -r 76104a4899ad -r 3f5f0c98cd18 mercurial/hgweb/protocol.py --- a/mercurial/hgweb/protocol.py Tue Jan 10 11:20:32 2017 -0800 +++ b/mercurial/hgweb/protocol.py Sat Dec 24 14:46:02 2016 -0700 @@ -25,6 +25,20 @@ HGTYPE = 'application/mercurial-0.1' HGERRTYPE = 'application/hg-error' +def decodevaluefromheaders(req, headerprefix): + """Decode a long value from multiple HTTP request headers.""" + chunks = [] + i = 1 + while True: + v = req.env.get('HTTP_%s_%d' % ( + headerprefix.upper().replace('-', '_'), i)) + if v is None: + break + chunks.append(v) + i += 1 + + return ''.join(chunks) + class webproto(wireproto.abstractserverproto): def __init__(self, req, ui): self.req = req @@ -53,15 +67,9 @@ args.update(cgi.parse_qs( self.req.read(postlen), keep_blank_values=True)) return args - chunks = [] - i = 1 - while True: - h = self.req.env.get('HTTP_X_HGARG_' + str(i)) - if h is None: - break - chunks += [h] - i += 1 - args.update(cgi.parse_qs(''.join(chunks), keep_blank_values=True)) + + argvalue = decodevaluefromheaders(self.req, 'X-HgArg') + args.update(cgi.parse_qs(argvalue, keep_blank_values=True)) return args def getfile(self, fp): length = int(self.req.env['CONTENT_LENGTH'])