Changeset - 21084a951cd9
[Not reviewed]
stable
0 2 0
Mads Kiilerich - 7 years ago 2018-10-11 02:06:50
mads@kiilerich.com
Grafted from: 61668afbc59b
hg: make __get_action command parsing simpler and safer
2 files changed with 6 insertions and 9 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/base.py
Show inline comments
 
@@ -218,7 +218,7 @@ class BaseVCSController(object):
 
        Checks permissions using action (push/pull) user and repository
 
        name
 

	
 
        :param action: push or pull action
 
        :param action: 'push' or 'pull' action
 
        :param user: `User` instance
 
        :param repo_name: repository name
 
        """
kallithea/lib/middleware/simplehg.py
Show inline comments
 
@@ -264,8 +264,7 @@ class SimpleHg(BaseVCSController):
 

	
 
    def __get_action(self, environ):
 
        """
 
        Maps mercurial request commands into a clone,pull or push command.
 
        This should always return a valid command string
 
        Maps Mercurial request commands into 'pull' or 'push'.
 

	
 
        :param environ:
 
        """
 
@@ -276,12 +275,10 @@ class SimpleHg(BaseVCSController):
 
                   'unbundle': 'push',
 
                   'pushkey': 'push', }
 
        for qry in environ['QUERY_STRING'].split('&'):
 
            if qry.startswith('cmd'):
 
                cmd = qry.split('=')[-1]
 
                if cmd in mapping:
 
                    return mapping[cmd]
 

	
 
                return 'pull'
 
            parts = qry.split('=', 1)
 
            if len(parts) == 2 and parts[0] == 'cmd':
 
                cmd = parts[1]
 
                return mapping.get(cmd, 'pull')
 

	
 
        raise Exception('Unable to detect pull/push action !!'
 
                        'Are you using non standard command or client ?')
0 comments (0 inline, 0 general)