Commit 067f96cc authored by faquin's avatar faquin
Browse files

Escape regex

Because we are building regex from random strings, we need to escape
them.
parent a0b50e77
...@@ -41,22 +41,22 @@ class RunningCommand: ...@@ -41,22 +41,22 @@ class RunningCommand:
return -1 return -1
def get_stdout_regex(self): def get_stdout_regex(self):
regex = "^.*{}-{}: {} \(.*\): output >.*".format(self.name, self.dest, regex = "^.*{}-{}: {} \(.*\): output >.*".format(re.escape(self.name),
self.command) re.escape(self.dest), re.escape(self.command))
logger.debug("regex -> ^.*{}-{}: {} \(.*\):" logger.debug("regex -> ^.*{}-{}: {} \(.*\):" " output >.*".format(re.escape(self.name),
" output >.*".format(self.name, self.dest, self.command)) re.escape(self.dest), re.escape(self.command)))
return re.compile(regex) return re.compile(regex)
def get_stderr_regex(self): def get_stderr_regex(self):
regex = "^.*{}-{}: {} \(.*\): error >.*".format(self.name, self.dest, regex = "^.*{}-{}: {} \(.*\): error >.*".format(re.escape(self.name),
self.command) re.escape(self.dest), re.escape(self.command))
logger.debug("regex -> ^.*{}-{}: {} \(.*\):" logger.debug("regex -> ^.*{}-{}: {} \(.*\):"
" error >.*".format(self.name, self.dest, self.command)) " error >.*".format(self.name, self.dest, self.command))
return re.compile(regex) return re.compile(regex)
def get_final_regex(self): def get_final_regex(self):
regex = "^.*{}-{}: {} \(.*\): status >.*".format(self.name, self.dest, regex = "^.*{}-{}: {} \(.*\): status >.*".format(re.escape(self.name),
self.command) re.escape(self.dest), re.escape(self.command))
logger.debug("regex -> ^.*{}-{}: {} \(.*\):" logger.debug("regex -> ^.*{}-{}: {} \(.*\):"
" status >.*".format(self.name, self.dest, self.command)) " status >.*".format(self.name, self.dest, self.command))
return re.compile(regex) return re.compile(regex)
......
Supports Markdown
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