| 507 | return url[start:delim], url[delim:] # return (domain, rest) |
| 508 | |
| 509 | def _checknetloc(netloc): |
| 510 | if not netloc or netloc.isascii(): |
| 511 | return |
| 512 | # looking for characters like \u2100 that expand to 'a/c' |
| 513 | # IDNA uses NFKC equivalence, so normalize for this check |
| 514 | import unicodedata |
| 515 | n = netloc.replace('@', '') # ignore characters already included |
| 516 | n = n.replace(':', '') # but not the surrounding text |
| 517 | n = n.replace('#', '') |
| 518 | n = n.replace('?', '') |
| 519 | netloc2 = unicodedata.normalize('NFKC', n) |
| 520 | if n == netloc2: |
| 521 | return |
| 522 | for c in '/?#@:': |
| 523 | if c in netloc2: |
| 524 | raise ValueError("netloc '" + netloc + "' contains invalid " + |
| 525 | "characters under NFKC normalization") |
| 526 | |
| 527 | def _check_bracketed_netloc(netloc): |
| 528 | # Note that this function must mirror the splitting |