Commit 5e71b60b authored by anonym's avatar anonym
Browse files

tor-controlport-filter: use named capture groups for increased readability.

parent 69f35e64
......@@ -422,13 +422,17 @@ def handle_controlport_session(controller, readh, writeh, client_desc, client_pi
if line.isspace():
_log('ignoring received empty (or whitespace-only) line')
match = re.match(r'(\S+)(\s*)([^\r\n]*)\r?\n$', line)
match = re.match(
r'(?P<cmd>\S+)(?P<cmd_arg_sep>\s*)(?P<arg_str>[^\r\n]*)\r?\n$', line
if not match:
_log("received bad line (escapes made explicit): " + repr(line))
# Hopefully the next line is ok...
cmd, cmd_arg_sep, arg_str = match.groups()
cmd ='cmd')
cmd_arg_sep ='cmd_arg_sep')
arg_str ='arg_str')
args = arg_str.split()
cmd = cmd.upper()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment