bpd: Process commands as bytes (fix #1388)

This commit is contained in:
Adrian Sampson 2015-03-31 07:13:13 -05:00
parent 882723a0bf
commit 8ae0317014

View file

@ -639,8 +639,8 @@ class Command(object):
"""A command issued by the client for processing by the server.
"""
command_re = re.compile(r'^([^ \t]+)[ \t]*')
arg_re = re.compile(r'"((?:\\"|[^"])+)"|([^ \t"]+)')
command_re = re.compile(br'^([^ \t]+)[ \t]*')
arg_re = re.compile(br'"((?:\\"|[^"])+)"|([^ \t"]+)')
def __init__(self, s):
"""Creates a new `Command` from the given string, `s`, parsing
@ -655,7 +655,7 @@ class Command(object):
if match[0]:
# Quoted argument.
arg = match[0]
arg = arg.replace('\\"', '"').replace('\\\\', '\\')
arg = arg.replace(b'\\"', b'"').replace(b'\\\\', b'\\')
else:
# Unquoted argument.
arg = match[1]