Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/protocol.py @ 34742:5a9cad0dfddb
hgweb: when unpacking args from request form, convert to bytes
We assume http-originated values are ASCII, which should be safe based
on the RFC.
Differential Revision: https://phab.mercurial-scm.org/D1110
author | Augie Fackler <augie@google.com> |
---|---|
date | Sun, 15 Oct 2017 00:41:34 -0400 |
parents | b2601c5977a4 |
children | dc2bf7074147 |
comparison
equal
deleted
inserted
replaced
34741:60143d038eb7 | 34742:5a9cad0dfddb |
---|---|
14 HTTP_OK, | 14 HTTP_OK, |
15 ) | 15 ) |
16 | 16 |
17 from .. import ( | 17 from .. import ( |
18 error, | 18 error, |
19 pycompat, | |
19 util, | 20 util, |
20 wireproto, | 21 wireproto, |
21 ) | 22 ) |
22 stringio = util.stringio | 23 stringio = util.stringio |
23 | 24 |
63 else: | 64 else: |
64 data[k] = knownargs[k][0] | 65 data[k] = knownargs[k][0] |
65 return [data[k] for k in keys] | 66 return [data[k] for k in keys] |
66 def _args(self): | 67 def _args(self): |
67 args = self.req.form.copy() | 68 args = self.req.form.copy() |
69 if pycompat.ispy3: | |
70 args = {k.encode('ascii'): [v.encode('ascii') for v in vs] | |
71 for k, vs in args.items()} | |
68 postlen = int(self.req.env.get('HTTP_X_HGARGS_POST', 0)) | 72 postlen = int(self.req.env.get('HTTP_X_HGARGS_POST', 0)) |
69 if postlen: | 73 if postlen: |
70 args.update(cgi.parse_qs( | 74 args.update(cgi.parse_qs( |
71 self.req.read(postlen), keep_blank_values=True)) | 75 self.req.read(postlen), keep_blank_values=True)) |
72 return args | 76 return args |