(label: str, start_descr: str, end_descr: str, is_hostname: bool)
| 442 | |
| 443 | |
| 444 | def check_dot_atom(label: str, start_descr: str, end_descr: str, is_hostname: bool) -> None: |
| 445 | # RFC 5322 3.2.3 |
| 446 | if label.endswith("."): |
| 447 | raise EmailSyntaxError(end_descr.format("period")) |
| 448 | if label.startswith("."): |
| 449 | raise EmailSyntaxError(start_descr.format("period")) |
| 450 | if ".." in label: |
| 451 | raise EmailSyntaxError("An email address cannot have two periods in a row.") |
| 452 | |
| 453 | if is_hostname: |
| 454 | # RFC 952 |
| 455 | if label.endswith("-"): |
| 456 | raise EmailSyntaxError(end_descr.format("hyphen")) |
| 457 | if label.startswith("-"): |
| 458 | raise EmailSyntaxError(start_descr.format("hyphen")) |
| 459 | if ".-" in label or "-." in label: |
| 460 | raise EmailSyntaxError("An email address cannot have a period and a hyphen next to each other.") |
| 461 | |
| 462 | |
| 463 | def uts46_valid_char(char: str) -> bool: |
no test coverage detected