MCPcopy Index your code
hub / github.com/python/cpython / _check_bracketed_netloc

Function _check_bracketed_netloc

Lib/urllib/parse.py:527–542  ·  view source on GitHub ↗
(netloc)

Source from the content-addressed store, hash-verified

525 "characters under NFKC normalization")
526
527def _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/

Callers 1

_urlsplitFunction · 0.85

Calls 4

_check_bracketed_hostFunction · 0.85
rpartitionMethod · 0.45
partitionMethod · 0.45
startswithMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…