| 422 | return url[start:delim], url[delim:] # return (domain, rest) |
| 423 | |
| 424 | def _checknetloc(netloc): |
| 425 | if not netloc or netloc.isascii(): |
| 426 | return |
| 427 | # looking for characters like \u2100 that expand to 'a/c' |
| 428 | # IDNA uses NFKC equivalence, so normalize for this check |
| 429 | import unicodedata |
| 430 | n = netloc.replace('@', '') # ignore characters already included |
| 431 | n = n.replace(':', '') # but not the surrounding text |
| 432 | n = n.replace('#', '') |
| 433 | n = n.replace('?', '') |
| 434 | netloc2 = unicodedata.normalize('NFKC', n) |
| 435 | if n == netloc2: |
| 436 | return |
| 437 | for c in '/?#@:': |
| 438 | if c in netloc2: |
| 439 | raise ValueError("netloc '" + netloc + "' contains invalid " + |
| 440 | "characters under NFKC normalization") |
| 441 | |
| 442 | def _check_bracketed_netloc(netloc): |
| 443 | # Note that this function must mirror the splitting |