a  ze#@sddlZddlZddlZddlmZedZdZdZddZ dd Z d d Z Gd d d ej Z Gdddej ZGdddejZGddde ejZGddde ejZddZdS)N) ucd_3_2_0u [.。.。]sxn--zxn--cCsg}|D] }t|rq|t|qd|}td|}|D]j}t|st|st |st |st |st |st |st|st|rDtd|qDdd|D}|D]:}|rtdd|Drtd|d r|d std q|S) NNFKCzInvalid character %rcSsg|]}t|qS) stringprepZ in_table_d1.0xrrB/opt/bitninja-python-dojo/embedded/lib/python3.9/encodings/idna.py )znameprep..css|]}t|VqdS)N)rZ in_table_d2rrrr 2r znameprep..zViolation of BIDI requirement 2rzViolation of BIDI requirement 3)rZ in_table_b1appendZ map_table_b2join unicodedata normalizeZ in_table_c12Z in_table_c22Z in_table_c3Z in_table_c4Z in_table_c5Z in_table_c6Z in_table_c7Z in_table_c8Z in_table_c9 UnicodeErrorany)labelZnewlabelcZRandALrrr nameprepsD      rcCsz|d}Wnty Yn*0dt|kr:dkrBnn|Stdt|}z|d}WntyrYn*0dt|krdkrnn|Std|trtd|d}t|}dt|krdkrnn|StddS)Nasciir@label empty or too longzLabel starts with ACE prefixpunycode)encoderlenr startswith sace_prefix ace_prefix)rrrr ToASCII>s,    r!cCst|trd}n*z|d}d}Wnty8d}Yn0|spt|}z|d}WntyntdYn0|tst|dS|ttd}| d}t |}t|d t|dkrtd|||S)NTrFzInvalid character in IDN labelrzIDNA does not round-trip) isinstancebytesrrrrr strrdecoder!lower)rZ pure_asciiZlabel1resultZlabel2rrr ToUnicodeis*         r(c@s eZdZdddZdddZdS) CodecstrictcCs|dkrtd||sdSz|d}Wnty<Ynd0|d}|ddD]&}dt|krpdksTntd qTt|ddkrtd |t|fSt}t|}|r|dsd}|d=nd }|D] }|r|d|t|qt ||t|fS) Nr*unsupported error handling r rr.rrrrzlabel too longr ) rrUnicodeEncodeErrorsplitr bytearraydotsextendr!r#)selfinputerrorsr'labelsr trailing_dotrrr rs4        z Codec.encodecCs|dkrtd||sdSt|ts.t|}t|vr^z|dt|fWSty\Yn0|d}|rt|ddkrd}|d=nd }g}|D]}|t |qd ||t|fS) Nr*Unsupported error handling rrrr-rr.r) rr"r#r r%rUnicodeDecodeErrorr/rr(r)r3r4r5r6r7r'rrrr r%s(    z Codec.decodeN)r*)r*)__name__ __module__ __qualname__rr%rrrr r)s %r)c@seZdZddZdS)IncrementalEncoderc Cs|dkrtd||sdSt|}d}|rT|dsBd}|d=n|sT|d=|rTd}t}d}|D]4}|r||d|d7}|t||t|7}qb||7}|t|7}t||fS) Nr*r+r,r rr-r)rr1r/r0r2r!rr# r3r4r5finalr6r7r'sizerrrr _buffer_encodes2    z!IncrementalEncoder._buffer_encodeN)r<r=r>rDrrrr r?sr?c@seZdZddZdS)IncrementalDecoderc Cs|dkrtd||sdSt|tr2t|}nt|d}|d}d}|rt|dsbd}|d=n|st|d=|rtd}g}d}|D]*}|t||r|d 7}|t|7}qd||}|t|7}||fS) Nr*r8r9rr:rrrr@) rr"r$r1r/rr(rrrArrr _buffer_decodes6      z!IncrementalDecoder._buffer_decodeN)r<r=r>rFrrrr rEsrEc@s eZdZdS) StreamWriterNr<r=r>rrrr rG$srGc@s eZdZdS) StreamReaderNrHrrrr rI'srIc Cs tjdtjtjttttdS)NZidna)namerr%incrementalencoderincrementaldecoder streamwriter streamreader) codecs CodecInfor)rr%r?rErGrIrrrr getregentry,srQ)rrerOrrcompiler1r rrr!r(r)BufferedIncrementalEncoderr?BufferedIncrementalDecoderrErGrIrQrrrr s  0+)H#'