51Degrees Pipeline for Python

fiftyone_pipeline_core.callback_url Namespace Reference

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.

See https://github.com/51Degrees/specifications/blob/main/pipeline-specification/pipeline-elements/javascript-builder.md#callback-url

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()

_checked_authority ( 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()

_checked_host_port ( 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()

_encoded ( text)
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()

_groups ( run,
ipv4_at_end )
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()

_is_ipv6 ( text)
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()

_is_port ( text)
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
protocolThe protocol, such as https @type host: str
hostThe host, which can start with user information and end with a port, a path, a query or a fragment @type endpoint: str
endpointThe 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
textThe part @rtype: bool
Returns
: True if the part is not a string, or is empty or only whitespace

Variable Documentation

◆ _DEC_OCTET

str fiftyone_pipeline_core.callback_url._DEC_OCTET = r"(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])"
protected

◆ AUTHORITY_END_PATTERN

fiftyone_pipeline_core.callback_url.AUTHORITY_END_PATTERN = re.compile(r"[/?#]")

◆ BLANK_PATTERN

fiftyone_pipeline_core.callback_url.BLANK_PATTERN
Initial value:
= re.compile(
r"[\t-\r \u0085\u00a0\u1680\u2000-\u200a"
r"\u2028\u2029\u202f\u205f\u3000]*")

◆ 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._~-]+")