U aD@sddlZddlmZddlmZddlmZddlmZe ej e e ddd Z de ej e ej eje ej efej ej e e d d d Zde e ej e ej e ej ee d ddZdS)N) _encode_idna) SecurityError) uri_to_iri) url_quote)hostname trusted_listreturnc Cs|sdSt|tr|g}ttddd}z ||}Wntk rJYdSX|D]p}|drp|dd}d}nd}z ||}Wntk rYdSX||krdS|rP|d |rPdSqPdS) 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)rr cSs d|kr|ddd}t|S)N:r)rsplitr)rr VC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-1tps7o9u\werkzeug\sansio\utils.py _normalizesz#host_is_trusted.._normalize.r NT.) isinstancestrbytes UnicodeError startswithendswith)rrrZhostname_bytesrefZ suffix_matchZ ref_bytesr r rhost_is_trusted s.       r)scheme host_headerserver trusted_hostsr cCsd}|dk r|}n.|dk r@|d}|ddk r@|d|d}|dkr`|dr`|dd}n|d kr~|d r~|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. Nrr r >httpwsz:80>httpswssz:443zHost z is not trusted.)rrr)rrrrhostr r rget_host8s   r&)rr% root_pathpath query_stringr cCs|d|g}|dkr*|dtd|S|t|d|d|dkr^td|S|t|d|r|d|t|ddtd|S)aRecreate 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)appendrjoinrrstriplstrip)rr%r'r(r)urlr r rget_current_urlhs    r2)NN)NNN)typingt _internalr exceptionsrurlsrrrIterableboolrOptionalTupleintr&rr2r r r rs2    2 3