iro/validate.py
branchdevel
changeset 130 05e599aa83c3
parent 129 d6704178a18f
child 136 ca926774e16c
equal deleted inserted replaced
129:d6704178a18f 130:05e599aa83c3
    63         
    63         
    64         if not re.match(r'^(\[[0-9\.]{7,16}\]|\[[0-9a-f:]{3,}\]|([a-z0-9+\-%_]+\.)+[a-z]{2,6})$',domain.lower()):
    64         if not re.match(r'^(\[[0-9\.]{7,16}\]|\[[0-9a-f:]{3,}\]|([a-z0-9+\-%_]+\.)+[a-z]{2,6})$',domain.lower()):
    65             raise InvalidMail(v,field)
    65             raise InvalidMail(v,field)
    66        
    66        
    67         if local == "":
    67         if local == "":
       
    68             ret.append(v)
    68             continue
    69             continue
    69         if local.startswith(".") or local.endswith("."):
    70         if local.startswith(".") or local.endswith("."):
    70             raise InvalidMail(v,field)
    71             raise InvalidMail(v,field)
    71         unquote = True
    72         unquote = True
    72         parts = local.split('"')
    73         parts = local.split('"')
    80                 if unquote and part != "" and len(parts) > 1 and part[-1] != '.': #quoted parts must be seperated by a dot
    81                 if unquote and part != "" and len(parts) > 1 and part[-1] != '.': #quoted parts must be seperated by a dot
    81                     raise InvalidMail(v,field)
    82                     raise InvalidMail(v,field)
    82                 unquote = not unquote
    83                 unquote = not unquote
    83                 c+=1
    84                 c+=1
    84             elif part == ''  or part[-1] != "\\":
    85             elif part == ''  or part[-1] != "\\":
    85                 if unquote  and part != "":         #quoted parts must be seperated by a dot
    86                 if unquote and part != "":         #quoted parts must be seperated by a dot
    86                     if part[0] != ".":
    87                     if part[0] != ".":
    87                         raise InvalidMail(v,field)
    88                         raise InvalidMail(v,field)
    88                     if i < len(parts)-1 and part[-1] != '.':
    89                     if i < len(parts)-1 and part[-1] != '.':
    89                         raise InvalidMail(v,field)
    90                         raise InvalidMail(v,field)
    90                 unquote = not unquote
    91                 unquote = not unquote