VirtualMailManager/VirtualMailManager.py
changeset 87 f9090d1a0730
parent 86 e43e4e7e9ec0
child 88 b3debcfea7bc
equal deleted inserted replaced
86:e43e4e7e9ec0 87:f9090d1a0730
   149         """Validates the domain name of an e-mail address.
   149         """Validates the domain name of an e-mail address.
   150         
   150         
   151         Keyword arguments:
   151         Keyword arguments:
   152         domainname -- the domain name that should be validated
   152         domainname -- the domain name that should be validated
   153         """
   153         """
   154         re.compile(RE_ASCII_CHARS)
       
   155         if not re.match(RE_ASCII_CHARS, domainname):
   154         if not re.match(RE_ASCII_CHARS, domainname):
   156             domainname = VirtualMailManager.idn2ascii(domainname)
   155             domainname = VirtualMailManager.idn2ascii(domainname)
   157         if len(domainname) > 255:
   156         if len(domainname) > 255:
   158             raise VMMException(_(u'The domain name is too long.'),
   157             raise VMMException(_(u'The domain name is too long.'),
   159                 ERR.DOMAIN_TOO_LONG)
   158                 ERR.DOMAIN_TOO_LONG)
   160         re.compile(RE_DOMAIN)
       
   161         if not re.match(RE_DOMAIN, domainname):
   159         if not re.match(RE_DOMAIN, domainname):
   162             raise VMMException(_(u'The domain name »%s« is invalid.') %\
   160             raise VMMException(_(u'The domain name »%s« is invalid.') %\
   163                     domainname, ERR.DOMAIN_INVALID)
   161                     domainname, ERR.DOMAIN_INVALID)
   164         return domainname
   162         return domainname
   165     chkDomainname = staticmethod(chkDomainname)
   163     chkDomainname = staticmethod(chkDomainname)
   303         """
   301         """
   304         os.umask(0007)
   302         os.umask(0007)
   305         oldpwd = os.getcwd()
   303         oldpwd = os.getcwd()
   306         os.chdir(domdir)
   304         os.chdir(domdir)
   307 
   305 
   308         re.compile(RE_MBOX_NAMES)
       
   309         maildir = self.__Cfg.get('maildir', 'name')
   306         maildir = self.__Cfg.get('maildir', 'name')
   310         folders = [maildir]
   307         folders = [maildir]
   311         for folder in self.__Cfg.get('maildir', 'folders').split(':'):
   308         for folder in self.__Cfg.get('maildir', 'folders').split(':'):
   312             folder = folder.strip()
   309             folder = folder.strip()
   313             if len(folder) and not folder.count('..')\
   310             if len(folder) and not folder.count('..')\
   581                     domain = pattern[1:-1]
   578                     domain = pattern[1:-1]
   582                 elif pattern.startswith('%'):
   579                 elif pattern.startswith('%'):
   583                     domain = pattern[1:]
   580                     domain = pattern[1:]
   584                 elif pattern.endswith('%'):
   581                 elif pattern.endswith('%'):
   585                     domain = pattern[:-1]
   582                     domain = pattern[:-1]
   586                 re.compile(RE_DOMAIN_SRCH)
       
   587                 if not re.match(RE_DOMAIN_SRCH, domain):
   583                 if not re.match(RE_DOMAIN_SRCH, domain):
   588                     raise VMMException(
   584                     raise VMMException(
   589                     _(u"The pattern »%s« contains invalid characters.") %
   585                     _(u"The pattern »%s« contains invalid characters.") %
   590                     pattern, ERR.DOMAIN_INVALID)
   586                     pattern, ERR.DOMAIN_INVALID)
   591         self.__dbConnect()
   587         self.__dbConnect()