diff mercurial/hgweb/hgweb_mod.py @ 36713:2442927cdd96

hgweb: convert req.form to bytes for all keys and values This is just going to be a lot cleaner for our internals. Differential Revision: https://phab.mercurial-scm.org/D2660
author Augie Fackler <augie@google.com>
date Sun, 04 Mar 2018 13:03:22 -0500
parents 7937850a523d
children 7bf80d9d9543
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py	Sun Mar 04 12:33:15 2018 -0500
+++ b/mercurial/hgweb/hgweb_mod.py	Sun Mar 04 13:03:22 2018 -0500
@@ -377,7 +377,7 @@
         # translate user-visible url structure to internal structure
 
         args = query.split('/', 2)
-        if r'cmd' not in req.form and args and args[0]:
+        if 'cmd' not in req.form and args and args[0]:
             cmd = args.pop(0)
             style = cmd.rfind('-')
             if style != -1:
@@ -386,7 +386,7 @@
 
             # avoid accepting e.g. style parameter as command
             if util.safehasattr(webcommands, cmd):
-                req.form[r'cmd'] = [cmd]
+                req.form['cmd'] = [cmd]
 
             if cmd == 'static':
                 req.form['file'] = ['/'.join(args)]
@@ -409,7 +409,7 @@
                         req.form['node'] = [fn[:-len(ext)]]
                         req.form['type'] = [type_]
         else:
-            cmd = pycompat.sysbytes(req.form.get(r'cmd', [r''])[0])
+            cmd = req.form.get('cmd', [''])[0]
 
         # process the web interface request
 
@@ -423,8 +423,8 @@
                 self.check_perm(rctx, req, None)
 
             if cmd == '':
-                req.form[r'cmd'] = [tmpl.cache['default']]
-                cmd = req.form[r'cmd'][0]
+                req.form['cmd'] = [tmpl.cache['default']]
+                cmd = req.form['cmd'][0]
 
             # Don't enable caching if using a CSP nonce because then it wouldn't
             # be a nonce.
@@ -433,7 +433,7 @@
             if cmd not in webcommands.__all__:
                 msg = 'no such method: %s' % cmd
                 raise ErrorResponse(HTTP_BAD_REQUEST, msg)
-            elif cmd == 'file' and r'raw' in req.form.get(r'style', []):
+            elif cmd == 'file' and 'raw' in req.form.get('style', []):
                 rctx.ctype = ctype
                 content = webcommands.rawfile(rctx, req, tmpl)
             else: