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')
continue
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...
continue
debug_log_recv(line)
cmd, cmd_arg_sep, arg_str = match.groups()
cmd = match.group('cmd')
cmd_arg_sep = match.group('cmd_arg_sep')
arg_str = match.group('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