Detailed Description
The callback URL the client script posts to for updated JSON.
The protocol and host usually come from the request, and the script holds the URL in a single-quoted string, so the URL is checked before it is written into the script. A URL that is not valid is refused. In the user information, in anything after the host and port, and in the endpoint, the characters a URL cannot hold or that could end the string or the script are percent-encoded.
Functions | |
| is_blank (text) | |
| Whether a part of the URL is not set. | |
| callback_url (protocol, host, endpoint) | |
| Build the callback URL from its parts and check it. | |
| _checked_authority (authority) | |
| The user information, host and port as they are written into the URL, or None when they are not valid. | |
| _checked_host_port (host_port) | |
| The host and optional port in lower case, or None when they are not valid. | |
| _is_port (text) | |
| Whether the text is ':' followed by digits whose value is no more than 65535, or by nothing. | |
| _is_ipv6 (text) | |
| Whether the text is an IPv6 address as RFC 3986 section 3.2.2 defines one. | |
| _groups (run, ipv4_at_end) | |
| The number of 16 bit groups in a run of groups separated by ':', or -1 when the run is not valid. | |
| _encoded (text) | |
| The text with each byte of its UTF-8 encoding percent-encoded where the byte is a control character, a space, outside ASCII or one of ENCODED_CHARACTERS, and with a '' encoded where two hexadecimal digits do not follow it. | |
Variables | |
| CallbackUrl = namedtuple("CallbackUrl", ["valid", "url"]) | |
| int | MAX_PORT = 65535 |
| int | MAX_PORT_DIGITS = 5 |
| ENCODED_CHARACTERS = frozenset(b"\"'<>\\^`{|}") | |
| HEX_DIGITS = frozenset(b"0123456789ABCDEFabcdef") | |
| BLANK_PATTERN | |
| SCHEME_PATTERN = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*") | |
| AUTHORITY_END_PATTERN = re.compile(r"[/?#]") | |
| LABEL_PATTERN = re.compile(r"[A-Za-z0-9_-]+") | |
| ZONE_PATTERN = re.compile(r"[A-Za-z0-9._~-]+") | |
| PORT_PATTERN = re.compile(r":[0-9]*") | |
| HEX_GROUP_PATTERN = re.compile(r"[0-9A-Fa-f]{1,4}") | |
| str | _DEC_OCTET = r"(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])" |
| IPV4_PATTERN = re.compile(_DEC_OCTET + r"(\." + _DEC_OCTET + r"){3}") | |
| SURROGATE_PATTERN = re.compile(r"[\ud800-\udfff]") | |
Function Documentation
◆ _checked_authority()
|
protected |
The user information, host and port as they are written into the URL, or None when they are not valid.
The user information ends at the first '@', so a second '@' is part of the host and refused.
◆ _checked_host_port()
|
protected |
The host and optional port in lower case, or None when they are not valid.
The host is an IPv6 address in brackets with an optional zone identifier, or a name of labels separated by dots with a dot allowed at the end. The port is ':' followed by digits up to 65535, or by nothing.
◆ _encoded()
|
protected |
The text with each byte of its UTF-8 encoding percent-encoded where the byte is a control character, a space, outside ASCII or one of ENCODED_CHARACTERS, and with a '' encoded where two hexadecimal digits do not follow it.
◆ _groups()
|
protected |
The number of 16 bit groups in a run of groups separated by ':', or -1 when the run is not valid.
An empty run has none, and an IPv4 address at the end of the run, where one is allowed, counts as two.
◆ _is_ipv6()
|
protected |
Whether the text is an IPv6 address as RFC 3986 section 3.2.2 defines one.
That is eight groups of one to four hexadecimal digits separated by ':', where one '::' can stand for one or more groups of zeros and the last two groups can be written as an IPv4 address.
◆ _is_port()
|
protected |
Whether the text is ':' followed by digits whose value is no more than 65535, or by nothing.
◆ callback_url()
| callback_url | ( | protocol, | |
| host, | |||
| endpoint ) |
Build the callback URL from its parts and check it.
One slash separates the host and the endpoint, being added when neither has one and removed when both do. The protocol and the host are written in lower case and the rest as given, apart from the percent-encoding.
@type protocol: str
- Parameters
-
protocol The protocol, such as https @type host: str host The host, which can start with user information and end with a port, a path, a query or a fragment @type endpoint: str endpoint The endpoint @rtype: CallbackUrl
- Returns
- : The callback URL, or None when the protocol, host or endpoint is not set
◆ is_blank()
| is_blank | ( | text | ) |
Whether a part of the URL is not set.
@type text: object
- Parameters
-
text The part @rtype: bool
- Returns
- : True if the part is not a string, or is empty or only whitespace
Variable Documentation
◆ _DEC_OCTET
|
protected |
◆ AUTHORITY_END_PATTERN
| fiftyone_pipeline_core.callback_url.AUTHORITY_END_PATTERN = re.compile(r"[/?#]") |
◆ BLANK_PATTERN
| fiftyone_pipeline_core.callback_url.BLANK_PATTERN |
◆ CallbackUrl
| fiftyone_pipeline_core.callback_url.CallbackUrl = namedtuple("CallbackUrl", ["valid", "url"]) |
◆ ENCODED_CHARACTERS
| fiftyone_pipeline_core.callback_url.ENCODED_CHARACTERS = frozenset(b"\"'<>\\^`{|}") |
◆ HEX_DIGITS
| fiftyone_pipeline_core.callback_url.HEX_DIGITS = frozenset(b"0123456789ABCDEFabcdef") |
◆ HEX_GROUP_PATTERN
| fiftyone_pipeline_core.callback_url.HEX_GROUP_PATTERN = re.compile(r"[0-9A-Fa-f]{1,4}") |
◆ IPV4_PATTERN
| fiftyone_pipeline_core.callback_url.IPV4_PATTERN = re.compile(_DEC_OCTET + r"(\." + _DEC_OCTET + r"){3}") |
◆ LABEL_PATTERN
| fiftyone_pipeline_core.callback_url.LABEL_PATTERN = re.compile(r"[A-Za-z0-9_-]+") |
◆ MAX_PORT
| int fiftyone_pipeline_core.callback_url.MAX_PORT = 65535 |
◆ MAX_PORT_DIGITS
| int fiftyone_pipeline_core.callback_url.MAX_PORT_DIGITS = 5 |
◆ PORT_PATTERN
| fiftyone_pipeline_core.callback_url.PORT_PATTERN = re.compile(r":[0-9]*") |
◆ SCHEME_PATTERN
| fiftyone_pipeline_core.callback_url.SCHEME_PATTERN = re.compile(r"[A-Za-z][A-Za-z0-9+.-]*") |
◆ SURROGATE_PATTERN
| fiftyone_pipeline_core.callback_url.SURROGATE_PATTERN = re.compile(r"[\ud800-\udfff]") |
◆ ZONE_PATTERN
| fiftyone_pipeline_core.callback_url.ZONE_PATTERN = re.compile(r"[A-Za-z0-9._~-]+") |
