Commit 2a3bb1b5 authored by Kai Willadsen's avatar Kai Willadsen

filters: Reuse re.compile checking in bytestring regexes

parent 59f061a0
......@@ -34,7 +34,7 @@ class FilterEntry:
@classmethod
def _compile_regex(cls, regex):
try:
compiled = re.compile("(?m)" + regex)
compiled = re.compile(regex, re.M)
except re.error:
compiled = None
return compiled
......@@ -46,11 +46,7 @@ class FilterEntry:
# encoding errors with '.'?
regex = regex.encode('utf8', 'replace')
try:
compiled = re.compile(b"(?m)" + regex)
except re.error:
compiled = None
return compiled
return cls._compile_regex(regex)
@classmethod
def _compile_shell_pattern(cls, pattern):
......
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