(netloc)
| 525 | "characters under NFKC normalization") |
| 526 | |
| 527 | def _check_bracketed_netloc(netloc): |
| 528 | # Note that this function must mirror the splitting |
| 529 | # done in NetlocResultMixins._hostinfo(). |
| 530 | hostname_and_port = netloc.rpartition('@')[2] |
| 531 | before_bracket, have_open_br, bracketed = hostname_and_port.partition('[') |
| 532 | if have_open_br: |
| 533 | # No data is allowed before a bracket. |
| 534 | if before_bracket: |
| 535 | raise ValueError("Invalid IPv6 URL") |
| 536 | hostname, _, port = bracketed.partition(']') |
| 537 | # No data is allowed after the bracket but before the port delimiter. |
| 538 | if port and not port.startswith(":"): |
| 539 | raise ValueError("Invalid IPv6 URL") |
| 540 | else: |
| 541 | hostname, _, port = hostname_and_port.partition(':') |
| 542 | _check_bracketed_host(hostname) |
| 543 | |
| 544 | # Valid bracketed hosts are defined in |
| 545 | # https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/ |
no test coverage detected
searching dependent graphs…