module documentation

Undocumented

Function base36_to_int Convert a base 36 string to an int. Raise ValueError if the input won't fit into an int.
Function escape_leading_slashes If redirecting to an absolute path (two leading slashes), a slash must be escaped to prevent browsers from handling the path as schemaless and redirecting to another host.
Function http_date Format the time to match the RFC1123 date format as specified by HTTP RFC7231 section 7.1.1.1.
Function int_to_base36 Convert an integer to a base36 string.
Function is_same_domain Return ``True`` if the host is either an exact match or a match to the wildcard pattern.
Function parse_etags Parse a string of ETags given in an If-None-Match or If-Match header as defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags should be matched.
Function parse_header_parameters Parse a Content-type like header. Return the main content-type and a dictionary of options.
Function parse_http_date Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.
Function parse_http_date_safe Same as parse_http_date, but return None if the input is invalid.
Function quote_etag If the provided string is already a quoted ETag, return it. Otherwise, wrap the string in quotes, making it a strong ETag.
Function url_has_allowed_host_and_scheme Return ``True`` if the url uses an allowed host and a safe scheme.
Function urlencode A version of Python's urllib.parse.urlencode() function that can operate on MultiValueDict and non-string values.
Function urlsafe_base64_decode Decode a base64 encoded string. Add back any trailing equal signs that might have been stripped.
Function urlsafe_base64_encode Encode a bytestring to a base64 string for use in URLs. Strip any trailing equal signs.
Constant ASCTIME_DATE Undocumented
Constant ETAG_MATCH Undocumented
Constant MONTHS Undocumented
Constant RFC1123_DATE Undocumented
Constant RFC3986_GENDELIMS Undocumented
Constant RFC3986_SUBDELIMS Undocumented
Constant RFC850_DATE Undocumented
Function _parseparam Undocumented
Function _url_has_allowed_host_and_scheme Undocumented
Function _urlparse Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e...
Function _urlsplit Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment> Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. ...
Constant __D Undocumented
Constant __D2 Undocumented
Constant __M Undocumented
Constant __T Undocumented
Constant __Y Undocumented
Constant __Y2 Undocumented
def base36_to_int(s): (source)

Convert a base 36 string to an int. Raise ValueError if the input won't fit into an int.

def escape_leading_slashes(url): (source)

If redirecting to an absolute path (two leading slashes), a slash must be escaped to prevent browsers from handling the path as schemaless and redirecting to another host.

def http_date(epoch_seconds=None): (source)

Format the time to match the RFC1123 date format as specified by HTTP RFC7231 section 7.1.1.1. `epoch_seconds` is a floating point number expressed in seconds since the epoch, in UTC - such as that outputted by time.time(). If set to None, it defaults to the current time. Output a string in the format 'Wdy, DD Mon YYYY HH:MM:SS GMT'.

def int_to_base36(i): (source)

Convert an integer to a base36 string.

def is_same_domain(host, pattern): (source)

Return ``True`` if the host is either an exact match or a match to the wildcard pattern. Any pattern beginning with a period matches a domain and all of its subdomains. (e.g. ``.example.com`` matches ``example.com`` and ``foo.example.com``). Anything else is an exact string match.

def parse_etags(etag_str): (source)

Parse a string of ETags given in an If-None-Match or If-Match header as defined by RFC 7232. Return a list of quoted ETags, or ['*'] if all ETags should be matched.

def parse_header_parameters(line): (source)

Parse a Content-type like header. Return the main content-type and a dictionary of options.

def parse_http_date(date): (source)

Parse a date format as specified by HTTP RFC7231 section 7.1.1.1. The three formats allowed by the RFC are accepted, even if only the first one is still in widespread use. Return an integer expressed in seconds since the epoch, in UTC.

def parse_http_date_safe(date): (source)

Same as parse_http_date, but return None if the input is invalid.

def quote_etag(etag_str): (source)

If the provided string is already a quoted ETag, return it. Otherwise, wrap the string in quotes, making it a strong ETag.

def url_has_allowed_host_and_scheme(url, allowed_hosts, require_https=False): (source)

Return ``True`` if the url uses an allowed host and a safe scheme. Always return ``False`` on an empty url. If ``require_https`` is ``True``, only 'https' will be considered a valid scheme, as opposed to 'http' and 'https' with the default, ``False``. Note: "True" doesn't entail that a URL is "safe". It may still be e.g. quoted incorrectly. Ensure to also use django.utils.encoding.iri_to_uri() on the path component of untrusted URLs.

def urlencode(query, doseq=False): (source)

A version of Python's urllib.parse.urlencode() function that can operate on MultiValueDict and non-string values.

def urlsafe_base64_decode(s): (source)

Decode a base64 encoded string. Add back any trailing equal signs that might have been stripped.

def urlsafe_base64_encode(s): (source)

Encode a bytestring to a base64 string for use in URLs. Strip any trailing equal signs.

ASCTIME_DATE = (source)

Undocumented

Value
_lazy_re_compile('^\\w{3} %s %s %s %s$'%(__M, __D2, __T, __Y))
ETAG_MATCH = (source)

Undocumented

Value
_lazy_re_compile('''
    \\A(      # start of string and capture group
    (?:W/)?  # optional weak indicator
    "        # opening quote
    [^"]*    # any sequence of non-quote characters
    "        # end quote
    )\\Z      # end of string and capture group
...

Undocumented

Value
"""jan feb mar apr may jun jul aug sep oct nov dec""".split()
RFC1123_DATE = (source)

Undocumented

Value
_lazy_re_compile('^\\w{3}, %s %s %s %s GMT$'%(__D, __M, __Y, __T))
RFC3986_GENDELIMS: str = (source)

Undocumented

Value
':/?#[]@'
RFC3986_SUBDELIMS: str = (source)

Undocumented

Value
'!$&\'()*+,;='
RFC850_DATE = (source)

Undocumented

Value
_lazy_re_compile('^\\w{6,9}, %s-%s-%s %s GMT$'%(__D, __M, __Y2, __T))
def _parseparam(s): (source)

Undocumented

def _url_has_allowed_host_and_scheme(url, allowed_hosts, require_https=False): (source)

Undocumented

def _urlparse(url, scheme='', allow_fragments=True): (source)

Parse a URL into 6 components: <scheme>://<netloc>/<path>;<params>?<query>#<fragment> Return a 6-tuple: (scheme, netloc, path, params, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.

def _urlsplit(url, scheme='', allow_fragments=True): (source)

Parse a URL into 5 components: <scheme>://<netloc>/<path>?<query>#<fragment> Return a 5-tuple: (scheme, netloc, path, query, fragment). Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.

Undocumented

Value
'(?P<day>[0-9]{2})'

Undocumented

Value
'(?P<day>[ 0-9][0-9])'

Undocumented

Value
'(?P<mon>\\w{3})'

Undocumented

Value
'(?P<hour>[0-9]{2}):(?P<min>[0-9]{2}):(?P<sec>[0-9]{2})'

Undocumented

Value
'(?P<year>[0-9]{4})'

Undocumented

Value
'(?P<year>[0-9]{2})'