comparison mercurial/hgweb/hgweb_mod.py @ 36864:4e06e8336634

hgweb: set variables in qsparams 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. Differential Revision: https://phab.mercurial-scm.org/D2780
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 12:11:26 -0800
parents 1a1972b1a1ff
children 3d60a22e27f5
comparison
equal deleted inserted replaced
36863:1a1972b1a1ff 36864:4e06e8336634
340 cmd = cmd[style + 1:] 340 cmd = cmd[style + 1:]
341 341
342 # avoid accepting e.g. style parameter as command 342 # avoid accepting e.g. style parameter as command
343 if util.safehasattr(webcommands, cmd): 343 if util.safehasattr(webcommands, cmd):
344 wsgireq.form['cmd'] = [cmd] 344 wsgireq.form['cmd'] = [cmd]
345 req.qsparams['cmd'] = cmd
345 346
346 if cmd == 'static': 347 if cmd == 'static':
347 wsgireq.form['file'] = ['/'.join(args)] 348 wsgireq.form['file'] = ['/'.join(args)]
349 req.qsparams['file'] = '/'.join(args)
348 else: 350 else:
349 if args and args[0]: 351 if args and args[0]:
350 node = args.pop(0).replace('%2F', '/') 352 node = args.pop(0).replace('%2F', '/')
351 wsgireq.form['node'] = [node] 353 wsgireq.form['node'] = [node]
354 req.qsparams['node'] = node
352 if args: 355 if args:
353 wsgireq.form['file'] = args 356 wsgireq.form['file'] = args
357 if 'file' in req.qsparams:
358 del req.qsparams['file']
359 for a in args:
360 req.qsparams.add('file', a)
354 361
355 ua = req.headers.get('User-Agent', '') 362 ua = req.headers.get('User-Agent', '')
356 if cmd == 'rev' and 'mercurial' in ua: 363 if cmd == 'rev' and 'mercurial' in ua:
357 req.qsparams['style'] = 'raw' 364 req.qsparams['style'] = 'raw'
358 365
360 fn = wsgireq.form['node'][0] 367 fn = wsgireq.form['node'][0]
361 for type_, spec in rctx.archivespecs.iteritems(): 368 for type_, spec in rctx.archivespecs.iteritems():
362 ext = spec[2] 369 ext = spec[2]
363 if fn.endswith(ext): 370 if fn.endswith(ext):
364 wsgireq.form['node'] = [fn[:-len(ext)]] 371 wsgireq.form['node'] = [fn[:-len(ext)]]
372 req.qsparams['node'] = fn[:-len(next)]
365 wsgireq.form['type'] = [type_] 373 wsgireq.form['type'] = [type_]
374 req.qsparams['type'] = type_
366 else: 375 else:
367 cmd = wsgireq.form.get('cmd', [''])[0] 376 cmd = wsgireq.form.get('cmd', [''])[0]
368 377
369 # process the web interface request 378 # process the web interface request
370 379
377 if cmd != 'static': 386 if cmd != 'static':
378 self.check_perm(rctx, wsgireq, None) 387 self.check_perm(rctx, wsgireq, None)
379 388
380 if cmd == '': 389 if cmd == '':
381 wsgireq.form['cmd'] = [tmpl.cache['default']] 390 wsgireq.form['cmd'] = [tmpl.cache['default']]
391 req.qsparams['cmd'] = tmpl.cache['default']
382 cmd = wsgireq.form['cmd'][0] 392 cmd = wsgireq.form['cmd'][0]
383 393
384 # Don't enable caching if using a CSP nonce because then it wouldn't 394 # Don't enable caching if using a CSP nonce because then it wouldn't
385 # be a nonce. 395 # be a nonce.
386 if rctx.configbool('web', 'cache') and not rctx.nonce: 396 if rctx.configbool('web', 'cache') and not rctx.nonce: