bg*>dZddlmZddlmZddlmZddlmZmZmZm Z m Z m Z gdZ ddl Z ddlZddlmZmZmZd Zd Zd Zed e d DZeZedejdzejdzD]Zeeee<deed<edD]Zeeee<dZdZdZdZd#dZ dZ!dZ"d$dZ#Gddej$Z%defdZ&efd Z'e'Z(e'Z)d!Z*d"Z+dS)%aFQuoted-printable content transfer encoding per RFCs 2045-2047. This module handles the content transfer encoding method defined in RFC 2045 to encode US ASCII-like 8-bit data called `quoted-printable'. It is used to safely encode text that is in a character set similar to the 7-bit US ASCII character set, but that includes some 8-bit characters that are normally not allowed in email bodies or headers. Quoted-printable is very space-inefficient for encoding binary files; use the email.base64mime module for that instead. This module provides an interface to encode and decode both headers and bodies with quoted-printable encoding. RFC 2045 defines a method for including character set information in an `encoded-word' in a header. This method is commonly used for 8-bit real names in To:/From:/Cc: etc. fields, as well as Subject: lines. This module does not do the line wrapping or end-of-line character conversion necessary for proper internationalized headers; it only does dumb encoding and decoding. To deal with the various line wrapping issues, use the email.header module. )unicode_literals)division)absolute_import)byteschrdictintrangesuper) body_decode body_encode body_lengthdecode decodestring header_decode header_encode header_lengthquoteunquoteN) ascii_lettersdigits hexdigits  c#$K|] }|d|zfV dS)=%02XN).0cs r/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/quoprimime.py r"<s+??q1gk*??????s-!*+/ascii_ s_ !"#$%&'()*+,-./0123456789:;<>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ c>t|t|kS)z>Return True if the octet should be escaped with header quopri.)r_QUOPRI_HEADER_MAPoctets r! header_checkr,Ns u::+E2 22r#c>t|t|kS)z.bs0EE%s%e,--EEEEEEr#sum bytearrays r!rrXs! EE9EEE E EEr#c4td|DS)zReturn a body quoted-printable encoding length. :param bytearray: An array of bytes (a.k.a. octets). :return: The length in bytes of the byte array when it is encoded with quoted-printable for bodies. c3JK|]}tt|VdSr2)r3r.r4s r!r"zbody_length..ls0CCs#E*++CCCCCCr#r5r7s r!rres! CCCCC C CCr#cnt|tst|}|s)||dSt |dt |z|kr|dxx||zz cc<dS||dS)N) isinstancestrrappendlstripr3)Lsmaxlenextras r! _max_appendrEos a   FF   QrUc!ff  & & " r#cLtt|dddS)zDTurn a string in the form =AB to the ASCII character with value 0xab)rr rBs r!rrzs s1QqS62  r#c&dt|zS)Nr)ord)r s r!rrs SVV r# iso-8859-1c|sdSg}|D]"}|t|#d|dt|dS)aEncode a single header line with quoted-printable (like) encoding. Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but used specifically for email header fields to allow charsets with mostly 7 bit characters (and some 8 bit) to remain more or less readable in non-RFC 2045 aware mail clients. charset names the character set to use in the RFC 2046 header. It defaults to iso-8859-1. rz=?z?q?z?=)r?r) EMPTYSTRINGjoin) header_bytescharsetencodedr+s r!rrsj rG22)%011112$GG[%5%5g%>%>%>%> ??r#c>eZdZfdZdZdZdZddZdZxZ S) _body_accumulatorcdtj|i|||_|x|_|_dSr2)r __init__eol maxlinelenroom)selfrYrXargskw __class__s r!rWz_body_accumulator.__init__s8$%"%%%&00$)))r#cj|||xjt|zc_dS)z%Add string s to the accumulated body.N)writerZr3)r[rBs r! write_strz_body_accumulator.write_strs+ 1  SVV r#cR||j|j|_dS)zWrite eol, then start new line.N)rarXrYrZr[s r!newlinez_body_accumulator.newlines# tx   O r#cX|d|dS)z*Write a soft break, then start a new line.=N)rardrcs r!write_soft_breakz"_body_accumulator.write_soft_breaks% s r#rc|jt||zkr|||dS)z.Add a soft line break if needed, then write s.N)rZr3rgra)r[rB extra_rooms r! write_wrappedz_body_accumulator.write_wrappedsD 9s1vv * * *  ! ! # # # qr#c|s||ddS|dvr||dS|jdkr$|t|dS|jdkr+|||dS||t|dS)NrG)riz rH)rjrZr`rrg)r[r is_last_chars r! write_charz_body_accumulator.write_chars !   qQ  / / / / / e^^   q ! ! ! ! ! Y!^^ JJuQxx Y!^^ JJqMMM  ! ! # # # # #  ! ! # # # JJuQxx r#)r) __name__ __module__ __qualname__rWrardrgrjrn __classcell__)r^s@r!rUrUs11111  $$$   !!!!!!!r#rULc|dkrtd|s|S|ddv}t||}|}t|dz }t |D]\}}t|dz } t |D]J\} } t t | rt| } || | | kK||ks|r| | S)aEncode with quoted-printable, wrapping at maxlinelen characters. Each line of encoded text will end with eol, which defaults to "\n". Set this to "\r\n" if you will be using the result of this function directly in an email. Each line will be wrapped at, at most, maxlinelen characters before the eol string (maxlinelen defaults to 76 characters, the maximum value permitted by RFC 2045). Long lines will have the 'soft line break' quoted-printable character "=" appended to them, so the decoded text will be identical to the original text. The minimum maxlinelen is 4 to have room for a quoted character ("=XX") followed by a soft line break. Smaller values will generate a ValueError. zmaxlinelen must be at least 4r<rrG) ValueErrorrU splitlinesr3 enumerater/rLrrnrdgetvalue) bodyrYrX last_has_eol encoded_bodylines last_line_noline_nolinelast_char_indexir s r!r r s!&A~~8999  H&L%Z55L OO  Eu::>L"5)) # # d))a-dOO ; ;DAq#a&&!! !HH  # #Aq/'9 : : : : \ ! !\ !  " " "  " ""r#c|s|Sd}|D]}|}|s||z }d}t|}||kr||}|dkr ||z }|dz }ni|dz|kr|dz }.|dz|krG||dztvr5||dztvr#|t |||dzz }|dz }n ||z }|dz }||kr||z }||k|ddvr||r |d d}|S) z_Decode a quoted-printable string. Lines are separated with eol, which defaults to \n. rrrfrGrlrHr<rN)rwrstripr3rrendswith)rSrXdecodedrrnr s r!rrsp G""$${{}}  sNG   II!eeQACxx1 Q1Q1qT!A#Y)33QqS Y8N8N74!A#;///Q1 QAvv3)!ee,r{&  W%5%5c%:%: #2#, Nr#cJ|d}t|S)zCTurn a match in the form =AB to the ASCII character with value 0xabr)groupr)matchrBs r!_unquote_matchr7s AA 1::r#cz|dd}tjdt|tjS)aDecode a string encoded with RFC 2045 MIME header `Q' encoding. This function does not parse a full MIME header value encoded with quoted-printable (like =?iso-8895-1?q?Hello_World?=) -- please use the high level email.header class for that functionality. r&r'z=[a-fA-F0-9]{2})replaceresubrASCIIrJs r!rr>s0 #sA 6$na B BBr#)r)rM),__doc__ __future__rrrfuture.builtinsrrrr r r __all__riostringrrrCRLFNLrOr)copyr.encoder rLr,r/rrrErrrStringIOrUr rr rrrrr#r!rs .('''''&&&&&&????????????????    3333333333   T??EE#JJ?????%**,, x.-.w777-&-:P:PP Q Q##ACFFq"33s88 3 4 4!!A#a&&Q 333 111 F F FDDD    @@@@.3!3!3!3!3! 3!3!3!l"$+#+#+#+#b,,,,`  CCCCCr#