Commit 4cad9d5c authored by anonym's avatar anonym
Browse files

tor-controlport-filter: deal better with rewrite_* vs CRLF.

Given how regexes match against \n, our old rewrite_line() would strip
any trailing \n, but leave \r.
parent f39a8f7d
......@@ -313,10 +313,14 @@ def handle_controlport_session(controller, readh, writeh, client_desc, client_pi
respond("510 Command filtered")
def rewrite_line(replacers, line):
terminator = ''
if line[-2:] == "\r\n":
terminator = "\r\n"
line = line[:-2]
for r in replacers:
match = re.match(r['pattern'] + "$", line)
if match:
return r['replacement'].format(*match.groups())
return r['replacement'].format(*match.groups()) + terminator
raise NoRewriteMatch()
def rewrite_matched_line(replacers, line):
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