##// END OF EJS Templates
hgweb: convert req.form to bytes for all keys and values...
Augie Fackler -
r36730:2442927c default
parent child Browse files
Show More
@@ -377,7 +377,7 b' class hgweb(object):'
377 377 # translate user-visible url structure to internal structure
378 378
379 379 args = query.split('/', 2)
380 if r'cmd' not in req.form and args and args[0]:
380 if 'cmd' not in req.form and args and args[0]:
381 381 cmd = args.pop(0)
382 382 style = cmd.rfind('-')
383 383 if style != -1:
@@ -386,7 +386,7 b' class hgweb(object):'
386 386
387 387 # avoid accepting e.g. style parameter as command
388 388 if util.safehasattr(webcommands, cmd):
389 req.form[r'cmd'] = [cmd]
389 req.form['cmd'] = [cmd]
390 390
391 391 if cmd == 'static':
392 392 req.form['file'] = ['/'.join(args)]
@@ -409,7 +409,7 b' class hgweb(object):'
409 409 req.form['node'] = [fn[:-len(ext)]]
410 410 req.form['type'] = [type_]
411 411 else:
412 cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0])
412 cmd = req.form.get('cmd', [''])[0]
413 413
414 414 # process the web interface request
415 415
@@ -423,8 +423,8 b' class hgweb(object):'
423 423 self.check_perm(rctx, req, None)
424 424
425 425 if cmd == '':
426 req.form[r'cmd'] = [tmpl.cache['default']]
427 cmd = req.form[r'cmd'][0]
426 req.form['cmd'] = [tmpl.cache['default']]
427 cmd = req.form['cmd'][0]
428 428
429 429 # Don't enable caching if using a CSP nonce because then it wouldn't
430 430 # be a nonce.
@@ -433,7 +433,7 b' class hgweb(object):'
433 433 if cmd not in webcommands.__all__:
434 434 msg = 'no such method: %s' % cmd
435 435 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
436 elif cmd == 'file' and r'raw' in req.form.get(r'style', []):
436 elif cmd == 'file' and 'raw' in req.form.get('style', []):
437 437 rctx.ctype = ctype
438 438 content = webcommands.rawfile(rctx, req, tmpl)
439 439 else:
@@ -48,9 +48,11 b' def normalize(form):'
48 48 form[name] = value
49 49 del form[k]
50 50 # And strip the values
51 bytesform = {}
51 52 for k, v in form.iteritems():
52 form[k] = [i.strip() for i in v]
53 return form
53 bytesform[pycompat.bytesurl(k)] = [
54 pycompat.bytesurl(i.strip()) for i in v]
55 return bytesform
54 56
55 57 class wsgirequest(object):
56 58 """Higher-level API for a WSGI request.
@@ -159,10 +159,10 b' def parsehttprequest(repo, req, query):'
159 159 # HTTP version 1 wire protocol requests are denoted by a "cmd" query
160 160 # string parameter. If it isn't present, this isn't a wire protocol
161 161 # request.
162 if r'cmd' not in req.form:
162 if 'cmd' not in req.form:
163 163 return None
164 164
165 cmd = pycompat.sysbytes(req.form[r'cmd'][0])
165 cmd = req.form['cmd'][0]
166 166
167 167 # The "cmd" request parameter is used by both the wire protocol and hgweb.
168 168 # While not all wire protocol commands are available for all transports,
General Comments 0
You need to be logged in to leave comments. Login now