OXIESEC PANEL
- Current Dir:
/
/
opt
/
alt
/
python311
/
lib
/
python3.11
/
site-packages
/
validators
Server IP: 2a02:4780:11:1594:0:ef5:22d7:a
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
01/09/2025 02:18:04 AM
rwxr-xr-x
📄
__init__.py
1.86 KB
05/14/2024 03:18:23 PM
rw-r--r--
📁
__pycache__
-
05/14/2024 03:18:23 PM
rwxr-xr-x
📄
_extremes.py
1.01 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
_tld.txt
9.4 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
between.py
2.39 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
btc_address.py
1.62 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
card.py
5.63 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
country.py
14.57 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
cron.py
2.23 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
domain.py
2.4 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
email.py
2.72 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
encoding.py
1.34 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
finance.py
3.22 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
hashes.py
3.21 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
hostname.py
4.05 KB
05/14/2024 03:18:23 PM
rw-r--r--
📁
i18n
-
05/14/2024 03:18:23 PM
rwxr-xr-x
📄
iban.py
1.05 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
ip_address.py
4.34 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
length.py
1.45 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
mac_address.py
865 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
py.typed
0 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
slug.py
750 bytes
05/14/2024 03:18:23 PM
rw-r--r--
📄
uri.py
1.78 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
url.py
7.23 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
utils.py
3.1 KB
05/14/2024 03:18:23 PM
rw-r--r--
📄
uuid.py
1.04 KB
05/14/2024 03:18:23 PM
rw-r--r--
Editing: email.py
Close
"""eMail.""" # standard import re # local from .hostname import hostname from .utils import validator @validator def email( value: str, /, *, ipv6_address: bool = False, ipv4_address: bool = False, simple_host: bool = False, rfc_1034: bool = False, rfc_2782: bool = False, ): """Validate an email address. This was inspired from [Django's email validator][1]. Also ref: [RFC 1034][2], [RFC 5321][3] and [RFC 5322][4]. [1]: https://github.com/django/django/blob/main/django/core/validators.py#L174 [2]: https://www.rfc-editor.org/rfc/rfc1034 [3]: https://www.rfc-editor.org/rfc/rfc5321 [4]: https://www.rfc-editor.org/rfc/rfc5322 Examples: >>> email('someone@example.com') # Output: True >>> email('bogus@@') # Output: ValidationError(email=email, args={'value': 'bogus@@'}) Args: value: eMail string to validate. ipv6_address: When the domain part is an IPv6 address. ipv4_address: When the domain part is an IPv4 address. simple_host: When the domain part is a simple hostname. rfc_1034: Allow trailing dot in domain name. Ref: [RFC 1034](https://www.rfc-editor.org/rfc/rfc1034). rfc_2782: Domain name is of type service record. Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782). Returns: (Literal[True]): If `value` is a valid eMail. (ValidationError): If `value` is an invalid eMail. """ if not value or value.count("@") != 1: return False username_part, domain_part = value.rsplit("@", 1) if len(username_part) > 64 or len(domain_part) > 253: # ref: RFC 1034 and 5231 return False if ipv6_address or ipv4_address: if domain_part.startswith("[") and domain_part.endswith("]"): # ref: RFC 5321 domain_part = domain_part.lstrip("[").rstrip("]") else: return False return ( bool( hostname( domain_part, skip_ipv6_addr=not ipv6_address, skip_ipv4_addr=not ipv4_address, may_have_port=False, maybe_simple=simple_host, rfc_1034=rfc_1034, rfc_2782=rfc_2782, ) ) if re.match( # extended latin r"(^[\u0100-\u017F\u0180-\u024F]" # dot-atom + r"|[-!#$%&'*+/=?^_`{}|~0-9a-z]+(\.[-!#$%&'*+/=?^_`{}|~0-9a-z]+)*$" # quoted-string + r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\011.])*"$)', username_part, re.IGNORECASE, ) else False )