/usr/local/lib/python3.6/site-packages/werkzeug/sansio/__pycache__
Edit: /usr/local/lib/python3.6/site-packages/werkzeug/sansio/__pycache__/utils.cpython-36.pyc (3833B)
3
_TBgD @ s d dl ZddlmZ ddlmZ ddlmZ ddlmZ e ej
e eddd Zde ej
e ej
eje ej
e f ej
ej
e e d
ddZde e ej
e ej
e ej
e e d
ddZdS ) N )_encode_idna)
SecurityError)
uri_to_iri) url_quote)hostnametrusted_listreturnc C s | sdS t |tr|g}ttddd}y|| }W n tk
rH dS X xp|D ]h}|jdrp|dd }d}nd}y||}W n tk
r dS X ||krdS |rP|jd | rPdS qPW dS )
zCheck if a host matches a list of trusted names.
:param hostname: The name to check.
:param trusted_list: A list of valid names to match. If a name
starts with a dot it will match all subdomains.
.. versionadded:: 0.9
F)r r c S s d| kr| j ddd } t| S )N: r )rsplitr )r r
9/tmp/pip-build-0s3hx122/Werkzeug/werkzeug/sansio/utils.py
_normalize s z#host_is_trusted.
._normalize.r NT .)
isinstancestrbytesUnicodeError
startswithendswith)r r r Zhostname_bytesrefZsuffix_matchZ ref_bytesr
r
r host_is_trusted s.
r )schemehost_headerserver
trusted_hostsr c C s d}|dk r|}n.|dk r@|d }|d dk r@| d|d }| dkr`|j dr`|dd }n| dkr~|j dr~|dd }|dk rt||std|d|S )a$ Return the host for the given parameters.
This first checks the ``host_header``. If it's not present, then
``server`` is used. The host will only contain the port if it is
different than the standard port for the protocol.
Optionally, verify that the host is trusted using
:func:`host_is_trusted` and raise a
:exc:`~werkzeug.exceptions.SecurityError` if it is not.
:param scheme: The protocol the request used, like ``"https"``.
:param host_header: The ``Host`` header value.
:param server: Address of the server. ``(host, port)``, or
``(path, None)`` for unix sockets.
:param trusted_hosts: A list of trusted host names.
:return: Host, with port if necessary.
:raise ~werkzeug.exceptions.SecurityError: If the host is not
trusted.
Nr r r
httpwsz:80 httpswssz:443 zHost z is not trusted.> r r > r# r" )r r r )r r r r hostr
r
r get_host8 s
r( )r r' root_pathpathquery_stringr c C s | d|g}|dkr*|j d tdj|S |j t|jd |j d |dkr^tdj|S |j t|jd |r|j d |j t|dd tdj|S )a Recreate the URL for a request. If an optional part isn't
provided, it and subsequent parts are not included in the URL.
The URL is an IRI, not a URI, so it may contain Unicode characters.
Use :func:`~werkzeug.urls.iri_to_uri` to convert it to ASCII.
:param scheme: The protocol the request used, like ``"https"``.
:param host: The host the request was made to. See :func:`get_host`.
:param root_path: Prefix that the application is mounted under. This
is prepended to ``path``.
:param path: The path part of the URL after ``root_path``.
:param query_string: The portion of the URL after the "?".
z://N/r ?z:&%=+$!*'(),)safe)appendr joinr rstriplstrip)r r' r) r* r+ urlr
r
r get_current_urlh s
r4 )NN)NNN)ZtypingtZ _internalr
exceptionsr urlsr r r Iterableboolr OptionalZTupleintr( r r4 r
r
r
r s 2 2.