From 0a02cfe9e8e65e68ec438bcd1c10fb7493f3e842 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 16 Jul 2013 14:39:42 -0400 Subject: [PATCH] ENH: must end with alphanumeric \w (not a dot or a dash etc) Otherwise regexp might swallow period in the sentence right after the address. I have decided to enforce alphanumeric instead of switching to non-greedy +? ... because I think it is closer to what we actually want here --- server/failregex.py | 2 +- testcases/servertestcase.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/failregex.py b/server/failregex.py index d302370b..bfa50575 100644 --- a/server/failregex.py +++ b/server/failregex.py @@ -41,7 +41,7 @@ class Regex: self._matchCache = None # Perform shortcuts expansions. # Replace "" with default regular expression for host. - regex = regex.replace("", "(?:::f{4,6}:)?(?P[\w\-.^_]+)") + regex = regex.replace("", "(?:::f{4,6}:)?(?P[\w\-.^_]*\w)") if regex.lstrip() == '': raise RegexException("Cannot add empty regex") try: diff --git a/testcases/servertestcase.py b/testcases/servertestcase.py index 0a5593e3..07cc373c 100644 --- a/testcases/servertestcase.py +++ b/testcases/servertestcase.py @@ -334,9 +334,9 @@ class Transmitter(TransmitterBase): "failed attempt from again", ], [ - "user john at (?:::f{4,6}:)?(?P[\w\-.^_]+)", - "Admin user login from (?:::f{4,6}:)?(?P[\w\-.^_]+)", - "failed attempt from (?:::f{4,6}:)?(?P[\w\-.^_]+) again", + "user john at (?:::f{4,6}:)?(?P[\w\-.^_]*\\w)", + "Admin user login from (?:::f{4,6}:)?(?P[\w\-.^_]*\\w)", + "failed attempt from (?:::f{4,6}:)?(?P[\w\-.^_]*\\w) again", ], self.jailName ) @@ -359,7 +359,7 @@ class Transmitter(TransmitterBase): ], [ "user john", - "Admin user login from (?:::f{4,6}:)?(?P[\w\-.^_]+)", + "Admin user login from (?:::f{4,6}:)?(?P[\w\-.^_]*\\w)", "Dont match me!", ], self.jailName