�
J�g� � �� � d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z
ddlmZm
Z
dZ ee� � ed � � z Z ej d
� � Zd� Zd� Zd
� Zdd�Zdd�Zd� Zd� Zd� Zd� ZdS )zc
authlib.util.urls
~~~~~~~~~~~~~~~~~
Wrapper functions for URL encoding and decoding.
� N��quote)�unquote)� urlencode� )�
to_unicode�to_byteszAABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.-z=&;:%+~,*@!()/?z&%[^0-9A-Fa-f]|%[0-9A-Fa-f][^0-9A-Fa-f]c � � g }| D ]6\ }}|� t |� � t |� � f� � �7t t |� � � � S �N)�appendr r �
_urlencode)�params�encoded�k�vs �c/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/authlib/common/urls.py�
url_encoder sV � ��G�� 3� 3���1��������X�a�[�[�1�2�2�2�2��j��)�)�*�*�*� c � � | rCt | � � t k s+d}t |t | � � t z
| fz � � �t � | � � rt d� � �t j | d�� � }g }|D ]6\ }}|� t |� � t |� � f� � �7|S )a� Decode a query string in x-www-form-urlencoded format into a sequence
of two-element tuples.
Unlike urlparse.parse_qsl(..., strict_parsing=True) urldecode will enforce
correct formatting of the query string by validation. If validation fails
a ValueError will be raised. urllib.parse_qsl will only raise errors if
any of name-value pairs omits the equals sign.
z�Error trying to decode a non urlencoded string. Found invalid characters: %s in the string: '%s'. Please ensure the request/response body is x-www-form-urlencoded.z%Invalid hex encoding in query string.T��keep_blank_values) �set�
urlencoded�
ValueError�INVALID_HEX_PATTERN�search�urlparse� parse_qslr r )�query�errorr �decodedr r s r �
url_decoder"