[PATCH 3 of 7] dispatch: rework the serve --stdio safe argument checks

Paul Morelle paul.morelle at octobus.net
Wed Jun 20 12:36:24 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1529489906 -7200
#      Wed Jun 20 12:18:26 2018 +0200
# Node ID 81edf3431b95d57257c690f7fe125c6676a78e18
# Parent  b7051e4bf783c844f705473a2396458acecc59dc
# EXP-Topic remote-debug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 81edf3431b95
dispatch: rework the serve --stdio safe argument checks

We prepare the code to check for arguments after the mandatory ones.

We want to relax this check to allow for wider argument passing in certain
conditions (example --debug). We make preliminary refactoring in different
changesets for clarity.

diff -r b7051e4bf783 -r 81edf3431b95 mercurial/dispatch.py
--- a/mercurial/dispatch.py	Wed Jun 20 12:16:48 2018 +0200
+++ b/mercurial/dispatch.py	Wed Jun 20 12:18:26 2018 +0200
@@ -285,12 +285,15 @@
             def unsafe():
                 msg = _('potentially unsafe serve --stdio invocation: %s')
                 raise error.Abort(msg % (stringutil.pprint(req.args),))
-            if (len(req.args) != 4 or
+            if (len(req.args) < 4 or
                 req.args[0] != '-R' or
                 req.args[1].startswith('--') or
                 req.args[2] != 'serve' or
                 req.args[3] != '--stdio'):
                 unsafe()
+            other_args = req.args[4:]
+            if other_args:
+                unsafe()
 
         try:
             debugger = 'pdb'


More information about the Mercurial-devel mailing list