diff --git a/src/utils/net.py b/src/utils/net.py index 8c899af94..5cc2276f1 100644 --- a/src/utils/net.py +++ b/src/utils/net.py @@ -31,8 +31,13 @@ Simple utility modules. """ +import re import socket +emailRe = re.compile(r"^(\w&.+-]+!)*[\w&.+-]+@" + r"(([0-9a-z]([0-9a-z-]*[0-9a-z])?\.)[a-z]{2,6}|" + r"([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I) + def getSocket(host): """Returns a socket of the correct AF_INET type (v4 or v6) in order to communicate with host. diff --git a/test/test_utils.py b/test/test_utils.py index ae86fd64d..80956ef2c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -385,6 +385,10 @@ class FileTest(SupyTestCase): class NetTest(SupyTestCase): + def testEmailRe(self): + emailRe = utils.net.emailRe + self.failUnless(emailRe.match('jemfinch@supybot.com')) + def testIsIP(self): isIP = utils.net.isIP self.failIf(isIP('a.b.c'))