D2780: hgweb: set variables in qsparams
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Sat Mar 10 20:57:44 UTC 2018
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
We currently mutate wsgireq.form in a few places. Since it is
independent from req.qsparams, we will need to make changes on
req.qsparams as well before consumers can use qsparams. So let's
do that.
Eventually, we'll delete wsgireq.form and all references to it.
REPOSITORY
rHG Mercurial
REVISION DETAIL
https://phab.mercurial-scm.org/D2780
AFFECTED FILES
mercurial/hgweb/hgweb_mod.py
CHANGE DETAILS
diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -342,15 +342,22 @@
# avoid accepting e.g. style parameter as command
if util.safehasattr(webcommands, cmd):
wsgireq.form['cmd'] = [cmd]
+ req.qsparams['cmd'] = cmd
if cmd == 'static':
wsgireq.form['file'] = ['/'.join(args)]
+ req.qsparams['file'] = '/'.join(args)
else:
if args and args[0]:
node = args.pop(0).replace('%2F', '/')
wsgireq.form['node'] = [node]
+ req.qsparams['node'] = node
if args:
wsgireq.form['file'] = args
+ if 'file' in req.qsparams:
+ del req.qsparams['file']
+ for a in args:
+ req.qsparams.add('file', a)
ua = req.headers.get('User-Agent', '')
if cmd == 'rev' and 'mercurial' in ua:
@@ -362,7 +369,9 @@
ext = spec[2]
if fn.endswith(ext):
wsgireq.form['node'] = [fn[:-len(ext)]]
+ req.qsparams['node'] = fn[:-len(next)]
wsgireq.form['type'] = [type_]
+ req.qsparams['type'] = type_
else:
cmd = wsgireq.form.get('cmd', [''])[0]
@@ -379,6 +388,7 @@
if cmd == '':
wsgireq.form['cmd'] = [tmpl.cache['default']]
+ req.qsparams['cmd'] = tmpl.cache['default']
cmd = wsgireq.form['cmd'][0]
# Don't enable caching if using a CSP nonce because then it wouldn't
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list