
    Yft                        d dl Z d dlmZ d dlmZ d dlmZ d dlmZm	Z	 d dl
mZ d dlmZ dZ e ed	d
dd           ded            G d de          Z G d de          Z e	e           G d d                      Z e	e           G d d                      Z e	e           G d d                      Z e	e           G d d                      Z G d d          Z G d d          Z ee j                  Z ee j                  Z ee j                  Z ee j                  Z ee j                   Z! ee j"                  Z# ee j$                  Z% ee j&                  Z' ee j(                  Z) ee j*                  Z+ ee j,                  Z- ee j.                  Z/ ee j0                  Z1 ee/e1geeeee!e#e%e'e)e+e- eg d          g          Z2 ee/geeee!e#e%e'e)e+e-g
          Z3 e            Z4dS )     N)idna)chain)	ucd_3_2_0)	Interfaceimplementer)Version)deprecatedModuleAttributeFTwisted      zcrippled is always Falsecrippledc                       e Zd ZdZd ZdS )ILookupTablez1
    Interface for character lookup classes.
    c                     dS )z<
        Return whether character is in this table.
        N cs    `/var/www/html/env/lib/python3.11/site-packages/twisted/words/protocols/jabber/xmpp_stringprep.pylookupzILookupTable.lookup             N)__name__
__module____qualname____doc__r   r   r   r   r   r      -             r   r   c                       e Zd ZdZd ZdS )IMappingTablez2
    Interface for character mapping classes.
    c                     dS )z/
        Return mapping for character.
        Nr   r   s    r   mapzIMappingTable.map)   r   r   N)r   r   r   r   r    r   r   r   r   r   $   r   r   r   c                       e Zd Zd ZdS )LookupTableFromFunctionc                     || _         d S N)r   selfin_table_functions     r   __init__z LookupTableFromFunction.__init__1   s    'r   Nr   r   r   r(   r   r   r   r"   r"   /   s#        ( ( ( ( (r   r"   c                       e Zd Zd Zd ZdS )LookupTablec                     || _         d S r$   _table)r&   tables     r   r(   zLookupTable.__init__7   s    r   c                     || j         v S r$   r-   r&   r   s     r   r   zLookupTable.lookup:   s    DKr   N)r   r   r   r(   r   r   r   r   r+   r+   5   s2                   r   r+   c                       e Zd Zd ZdS )MappingTableFromFunctionc                     || _         d S r$   )r    )r&   map_table_functions     r   r(   z!MappingTableFromFunction.__init__@   s    %r   Nr)   r   r   r   r3   r3   >   s#        & & & & &r   r3   c                       e Zd Zd Zd ZdS )EmptyMappingTablec                     || _         d S r$   _in_table_functionr%   s     r   r(   zEmptyMappingTable.__init__F   s    "3r   c                 4    |                      |          rd S |S r$   r9   r1   s     r   r    zEmptyMappingTable.mapI   s"    ""1%% 	4Hr   N)r   r   r   r(   r    r   r   r   r7   r7   D   s2        4 4 4    r   r7   c                   >    e Zd Zg dg ddfdZd Zd Zd Zd Zd ZdS )	ProfileTc                 L    || _         || _        || _        || _        || _        d S r$   )mappings	normalizeprohibitedsdo_check_unassignedsdo_check_bidi)r&   r?   r@   rA   check_unassigneds
check_bidis         r   r(   zProfile.__init__Q   s0     !"&$5!'r   c                    |                      |          }| j        rt          j        d|          }|                     |           | j        r|                     |           | j        r|                     |           |S )NNFKC)r    r@   unicodedatacheck_prohibitedsrB   rD   rC   check_bidirectionals)r&   stringresults      r   preparezProfile.prepare_   s    &!!> 	; *66::Fv&&&$ 	+""6*** 	.%%f---r   c                     g }|D ]B}|}| j         D ]}|                    |          }||k    r n ||                    |           Cd                    |          S )N )r?   r    appendjoin)r&   rK   rL   r   result_cmappings         r   r    zProfile.mapj   sy     		( 		(AH=  ";;q>>q==E ! #h'''wwvr   c                     |D ]@}| j         D ]6}|                    |          rt          dt          |          z            7Ad S NzInvalid character %s)rA   r   UnicodeErrorrepr)r&   rK   r   r/   s       r   rI   zProfile.check_prohibitedsz   sl     	I 	IA) I I<<?? I&'=Q'GHHHII	I 	Ir   c                 v    |D ]5}t          j        |          rt          dt          |          z            6d S )NzUnassigned code point %s)
stringprepin_table_a1rV   rW   r&   rK   r   s      r   rD   zProfile.check_unassigneds   sS     	I 	IA%a(( I"#=Q#GHHHI	I 	Ir   c                 $   d}d}|D ].}t          j        |          rd}t          j        |          rd}/|r|rt          d          |rCt          j        |d                   rt          j        |d                   st          d          d S d S )NFTzViolation of BIDI Requirement 2r   zViolation of BIDI Requirement 3)rY   in_table_d1in_table_d2rV   )r&   rK   
found_LCatfound_RandALCatr   s        r   rJ   zProfile.check_bidirectionals   s    
 	" 	"A%a(( '"&%a(( "!
 	B/ 	B@AAA 	B"6!9--	B2<2HPR2T2T	B @AAA	B 	B 	B 	Br   N)	r   r   r   r(   rM   r    rI   rD   rJ   r   r   r   r=   r=   P   s         ( ( ( (	 	 	   I I II I I
B B B B Br   r=   c                       e Zd ZdZd  e edd           edd           edd           ed	d
           edd                    D             Zd Zd Zd Z	dS )NamePrepa  Implements preparation of internationalized domain names.

    This class implements preparing internationalized domain names using the
    rules defined in RFC 3491, section 4 (Conversion operations).

    We do not perform step 4 since we deal with unicode representations of
    domain names and do not convert from or to ASCII representations using
    punycode encoding. When such a conversion is needed, the C{idna} standard
    library provides the C{ToUnicode()} and C{ToASCII()} functions. Note that
    C{idna} itself assumes UseSTD3ASCIIRules to be false.

    The following steps are performed by C{prepare()}:

      - Split the domain name in labels at the dots (RFC 3490, 3.1)
      - Apply nameprep proper on each label (RFC 3491)
      - Enforce the restrictions on ASCII characters in host names by
        assuming STD3ASCIIRules to be true. (STD 3)
      - Rejoin the labels using the label separator U+002E (full stop).

    c                 ,    g | ]}t          |          S r   )chr).0ns     r   
<listcomp>zNamePrep.<listcomp>   s.     	 	 	 	A	 	 	r   r   -   .   0   :   A   [   a   {      c                    g }t           j                            |          }|rt          |d                   dk    rd}|d= nd}|D ]*}|                    |                     |                     +d                    |          |z   S )Nr]   r   .rO   )r   dotssplitlenrP   namepreprQ   )r&   rK   rL   labelstrailing_dotlabels         r   rM   zNamePrep.prepare   s    (( 	c&*oo**Lr

L 	0 	0EMM$--..////xx,..r   c                 `    |D ]*}|| j         v rt          dt          |          z            +d S rU   )rA   rV   rW   r[   s      r   rI   zNamePrep.check_prohibiteds   sL     	E 	EAD$$$"#9DGG#CDDD %	E 	Er   c                     t          j        |          }|                     |           |d         dk    rt          d          |d         dk    rt          d          |S )Nr   -zInvalid leading hyphen-minusr]   zInvalid trailing hyphen-minus)r   rw   rI   rV   )r&   rz   s     r   rw   zNamePrep.nameprep   sd    e$$u%%%8s??=>>>9>???r   N)
r   r   r   r   r   rangerA   rM   rI   rw   r   r   r   rc   rc      s         ,	 	E$!!E$!!E$!!E$!!E$!!
 
	 	 	K/ / / E E E
    r   rc   )"&'/:<>@)r?   rA   )5rY   	encodingsr   	itertoolsr   rH   r   zope.interfacer   r   incrementalr   twisted.python.deprecater	   r   r   r   r   r"   r+   r3   r7   r=   rc   in_table_c11C_11in_table_c12C_12in_table_c21C_21in_table_c22C_22in_table_c3C_3in_table_c4C_4in_table_c5C_5in_table_c6C_6in_table_c7C_7in_table_c8C_8in_table_c9C_9in_table_b1B_1map_table_b2B_2nodeprepresourcepreprw   r   r   r   <module>r      s                   1 0 0 0 0 0 1 1 1 1 1 1 1 1       > > > > > >  GIr1a  "<h
  
    9       I    \( ( ( ( ( ( ( (
 \                ]& & & & & & & &
 ]       EB EB EB EB EB EB EB EBP> > > > > > > >B z677z677z677z677j455j455j455j455j455j455j455
.//z67773Z<<<==  $ w tT3S#sCE	   8::r   