� J�g�����dZddlZddlmZddlmZddlmZddlm Z ddl m Z m Z dZee��ed ��zZejd ��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���7tt|����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_encodersV���G��3�3���1������ � �X�a�[�[�1�2�2�2�2� �j��)�)� *� *�*�c��|rCt|��tks+d}t|t|��tz |fz���t�|��rtd���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�decodedrrs r� url_decoder" s��� �C�S��Z�Z�:�-�-�*�� ��#�e�*�*�z�"9�5�!A�A�B�B�B� �!�!�%�(�(�B��@�A�A�A�&� ��� >� >� >�F��G��7�7���1���� �1� � �z�!�}�}�5�6�6�6�6� �Nrc���t|t��r|���}tj|d���}|�|��t |��S)z)Extend a query with a list of two-tuples.Tr)� isinstance�dict�itemsrr�extendr)rr�qss r�add_params_to_qsr)SsT���&�$��� ������� � �E�T� :� :� :�B��I�I�f���� �b�>�>�rFc��tj|��\}}}}}}|rt||��}nt||��}tj||||||f��S)z5Add a list of two-tuples to the uri query components.)rr)� urlunparse) �urir�fragment�sch�net�path�parr�fras r�add_params_to_urir3]se��&.�&7��&<�&<�#�C��d�C����0��s�F�+�+��� ���/�/�� � ��S�$��U�C�@� A� A�Ar�/c�V�ttt|��|����Sr )r�_quoter )�s�safes rrrgs �� �f�X�a�[�[�$�/�/� 0� 0�0rc�:�tt|����Sr )r�_unquote�r7s rrrks�� �h�q�k�k� "� "�"rc�"�t|d��S)Ns~@#$&()*!+=:;,.?/'rr;s r� quote_urlr=os�� ��*� +� +�+rc��t|ttf��r) t|��}n#tt f$rYdSwxYwt|t��rOg}|���D]6\}}|�t|��t|��f���7|S|sdS t|��S#t $rYdSwxYw)a*Extract parameters and return them as a list of 2-tuples. Will successfully extract parameters from urlencoded query strings, dicts, or lists of 2-tuples. Empty strings/dicts/lists will return an empty list of parameters. Any other input will result in a return value of None. N) r$�list�tupler%� TypeErrorrr&r rr")�rawrrrs r�extract_paramsrCss����#��e�}�%�%�� ��s�)�)�C�C���:�&� � � ��4�4� �����#�t�������I�I�K�K� :� :�D�A�q� �M�M�:�a�=�=�*�Q�-�-�8� 9� 9� 9� 9�� � ���t���#����� �����t�t����s!�.�A�A�/B>�> C � C c�F�tj|��}|jo|jSr )r�scheme�hostname)�url�parseds r� is_valid_urlrI�s!�� � �s� #� #�F� �=� ,�V�_�,r)F)r4)�__doc__�re� urllib.parserr6rr:rr �parser�encodingrr � always_saferr�compilerrr"r)r3r=rCrI�rr�<module>rRsX���� � � � �(�(�(�(�(�(�,�,�,�,�,�,�0�0�0�0�0�0�������*�*�*�*�*�*�*�*�� � �S�� � ���$5� 6� 6� 6� � �b�j�!J�K�K��+�+�+�0�0�0�f���B�B�B�B�1�1�1�1�#�#�#�,�,�,����:-�-�-�-�-r
Memory