File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/__pycache__/saslprep.cpython-310.pyc
o
�N�g� � @ st d Z zddlZW n ey dZdd� ZY dS w dZddlZejejejej ej
ejejej
ejf Zddd�ZdS ) z&An implementation of RFC4013 SASLprep.� NFc C s t | t�r td��| S )zSASLprep dummyzVThe stringprep module is not available. Usernames and passwords must be ASCII strings.)�
isinstance�str� TypeError)�data� r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/ext/saslprep.py�saslprep s
�r Tc s� t | t�s| S |rttjf }nt}tj�tj�d���fdd�| D ��} tj �
d| �} tj}|| d �rF|| d �s?td��|tj
f }n||f }| D ]� t� fdd �|D ��r^td
��qM| S )a� An implementation of RFC4013 SASLprep.
:Parameters:
- `data`: The string to SASLprep. Unicode strings
(python 2.x unicode, 3.x str) are supported. Byte strings
(python 2.x str, 3.x bytes) are ignored.
- `prohibit_unassigned_code_points`: True / False. RFC 3454
and RFCs for various SASL mechanisms distinguish between
`queries` (unassigned code points allowed) and
`stored strings` (unassigned code points prohibited). Defaults
to ``True`` (unassigned code points are prohibited).
:Returns:
The SASLprep'ed version of `data`.
� c s$ g | ]}� |�s�|�rd n|�qS )� r )�.0�elt)�in_table_b1�in_table_c12r r �
<listcomp>P s �zsaslprep.<locals>.<listcomp>�NFKCr ���z$SASLprep: failed bidirectional checkc 3 s � | ]}|� �V qd S )Nr )r Zin_table)�charr r � <genexpr>i s � zsaslprep.<locals>.<genexpr>z+SASLprep: failed prohibited character check)r r �_PROHIBITED�
stringprepZin_table_a1r r
�join�unicodedata� ucd_3_2_0� normalize�in_table_d1�
ValueErrorZin_table_d2�any)r Zprohibit_unassigned_code_pointsZ
prohibitedr r )r r
r r r 1 s4
��
��)T)�__doc__r �ImportErrorZHAVE_STRINGPREPr r r Zin_table_c21_c22Zin_table_c3Zin_table_c4Zin_table_c5Zin_table_c6Zin_table_c7Zin_table_c8Zin_table_c9r r r r r �<module> s( ��