bg_dZddlmZddlmZddlmZddlmZmZmZm Z m Z gdZ ddl Z ddl Z ddlmZdd lmZdd lmZddlmcmcmZdd lmZmZejZd Zd ZdZdZdZ dZ!dZ"edZ#edZ$e j%de j&e j'ze j(zZ)e j%dZ*e j%dZ+dZ, d dZ-Gdde.Z/Gdde.Z0Gdde1Z2dS)!z+Header encoding and decoding functionality.)unicode_literals)division)absolute_import)bytesrangestrsuperzip)Header decode_header make_headerN)email) base64mime)HeaderParseError) _max_append header_decode   z Nz us-asciizutf-8ai =\? # literal =? (?P[^?]*?) # non-greedy up to the next ? is the charset \? # literal ? (?P[qb]) # either a "q" or a "b", case insensitive \? # literal ? (?P.*?) # non-greedy up to the next ?= is the encoded string \?= # literal ?= z[\041-\176]+:$z \n[^ \t]+:c\t|drd|jDSt|s|dfgSg}|D]}t|}d}|r|d}|r|}d}|r||ddf|r{|d }|d }|d}||||f|ƌddl } g} t|D]_\} } | dkrT| drL|| dz dr;|| dz d r| | dz `t| D]} || =g}|D]\}}}||||f |d kr't|}|||fM|d krst|d z}|r|d dd |z z } t!j|}|||f#t$j$rt)d wxYwt+d|zg}dx}}|D]h\}}t-|t.rt1|d}||}|}1||kr|||f|}|}S||t2|zz }c||z }i|||f|S)a;Decode a message header value without converting charset. Returns a list of (string, charset) pairs containing each of the decoded parts of the header. Charset is None for non-encoded parts of the header, otherwise a lower-case string containing the name of the character set specified in the encoded string. header may be a string that may or may not contain RFC2047 encoded words, or it may be a Header object. An email.errors.HeaderParseError may be raised when certain decoding error occurs (e.g. a base64 decoding exception). _chunkscvg|]6\}}tj|t|t|f7S)_charset_encoder).0stringcharsets n/builddir/build/BUILD/cloudlinux-venv-1.0.7/venv/lib/python3.11/site-packages/future/backports/email/header.py z!decode_header..NsJ;;;'!&#g,,77WF;;;NTrFqbz===zBase64 decoding errorzUnexpected encoding: zraw-unicode-escape)hasattrrecresearch splitlinessplitpoplstripappendlowersys enumerateisspacereversedrlenrdecodebinasciiErrorrAssertionError isinstancerrBSPACE)headerwordslinepartsfirst unencodedr!encodingencodedr3droplistnwd decoded_wordsencoded_stringwordpaderr collapsed last_word last_charsets r"r r >svy!!;;;+1>;;; ; ;;v    E!!##;; 4   ; ! I %,,..  6 it4555 ;))A,,,,.. 99Q<<--//))A,, gx9::: ;JJJH%  !!1 Q331Q43E!A#JqM3eAaCjm.C.C.E.E3 OOAaC h   !HH M-2EE)'    .'!: ; ; ; ; __ 00D  $ 1 1 1 1 __((1,F 5% V "44 6!(88$$dG_5555> @ @ @&'>??? @ !!88!CDD DI##I &   g dC  5344D  I"LL  $ $   i6 7 7 7I"LL  ! $ &II  II i./// s I00Jct|||}|D]A\}}|$t|tst|}|||B|S)aCreate a Header from a sequence of pairs as returned by decode_header() decode_header() takes a header value string and returns a sequence of pairs of the format (decoded_string, charset) where charset is the string name of the character set. This function takes one of those sequence of pairs and returns a Header instance. Optional maxlinelen, header_name, and continuation_ws are as in the Header constructor. ) maxlinelen header_namecontinuation_ws)r r<Charsetr1) decoded_seqrRrSrThsr!s r"r r sp *+. 0 0 0A! 7  z'7'C'C g&&G G Hr$cJeZdZ ddZdZdZdZddZd Zdd Z d Z dS)r Nrstrictc"|t}n$t|tst|}||_||_g|_||||||t}||_| d|_ dSt|dz|_ dS)aDCreate a MIME-compliant header that can contain many character sets. Optional s is the initial header value. If None, the initial header value is not set. You can later append to the header with .append() method calls. s may be a byte string or a Unicode string, but see the .append() documentation for semantics. Optional charset serves two purposes: it has the same meaning as the charset argument to the .append() method. It also sets the default character set for all subsequent .append() calls that omit the charset argument. If charset is not provided in the constructor, the us-ascii charset is used both as s's initial charset and as the default for subsequent .append() calls. The maximum line length can be specified explicitly via maxlinelen. For splitting the first line to a shorter value (to account for the field header which isn't included in s, e.g. `Subject') pass in the name of the field in header_name. The default maxlinelen is 78 as recommended by RFC 2822. continuation_ws must be RFC 2822 compliant folding whitespace (usually either a space or a hard tab) which will be prepended to continuation lines. errors is passed through to the .append() call. Nrr&) USASCIIr<rUr_continuation_wsrr1 MAXLINELEN _maxlinelen _headerlenr7)selfrXr!rRrSrTerrorss r"__init__zHeader.__init__s: ?GGGW-- 'g&&G / = KK7F + + +  #J%  DOOO"+..2DOOOr$c4|g}d}d}|jD]\}}|}|tjkr,|dd}|dd}|rd|o||d}|dvr#|dvr|s|td}n |dvr|s|t|o||d}|}||t |S)z&Return the string value of the header.NasciisurrogateescapereplacerNr) _normalizerr UNKNOWN8BITencoder8 _nonctextr1SPACE EMPTYSTRINGjoin) rauchunkslastcs lastspacer r!nextcsoriginal_byteshasspaces r"__str__zHeader.__str__s6  #| # #OFGF---!'w8I!J!J'..w BB *!?dnnVAY&?&?!333!333H3u---!%#555i5NN5)))=4>>&*#=#=IF NN6 " " " "(((r$c(|t|kSN)rraothers r"__eq__z Header.__eq__sD !!r$c||k Sryrrzs r"__ne__z Header.__ne__ s5=  r$c||j}n$t|tst|}t|tsF|jpd}|tjkr|dd}n|||}|jpd}|tjkr6 |||n#t$r|dkrt}YnwxYw|j ||fdS)a.Append a string to the MIME header. Optional charset, if given, should be a Charset instance or the name of a character set (which will be converted to a Charset instance). A value of None (the default) means that the charset given in the constructor is used. s may be a byte string or a Unicode string. If it is a byte string (i.e. isinstance(s, str) is false), then charset is the encoding of that byte string, and a UnicodeError will be raised if the string cannot be decoded with that charset. If s is a Unicode string, then charset is a hint specifying the character set of the characters in the string. In either case, when producing an RFC 2822 compliant header using RFC 2047 rules, the string will be encoded using the output codec of the charset. If the string cannot be encoded to the output codec, a UnicodeError will be raised. Optional `errors' is passed as the errors argument to the decode call if s is a byte string. Nrrf) rr<rUr input_codecrkr8 output_codecrlUnicodeEncodeErrorUTF8rr1)rarXr!rb input_charsetoutput_charsets r"r1z Header.append s* ?mGGGW-- 'g&&G!S!! 4#/=:M 444HHZ):;;HH]F33!-; X1 1 1 0000%   !:--  QL)))))s$B;;CCc2|p|dvS)z=True if string s is not a ctext character of RFC822. )()\)r5)rarXs r"rmzHeader._nonctext7syy{{3a#333r$;, rc|||j}|dkrd}t|j||j|}d}dx}}|jD]\}} |Z|o||d}ddl} |dvr|r| dvr|n| dvr|s||o||d}| }d}| } | r| d| d| n| dd| | ddD]} | | j 2| |jd | z| O| } | dt| t| z }| || | t| dkr| |jr|||}t |r"t%d ||S) aEncode a message header into an RFC-compliant format. There are many issues involved in converting a given string for use in an email header. Only certain character sets are readable in most email clients, and as header strings can only contain a subset of 7-bit ASCII, care must be taken to properly convert and encode (with Base64 or quoted-printable) header strings. In addition, there is a 75-character length limit on any given encoded header field, so line-wrapping must be performed, even with double-byte character sets. Optional maxlinelen specifies the maximum length of each generated line, exclusive of the linesep string. Individual lines may be longer than maxlinelen if a folding point cannot be found. The first line will be shorter by the length of the header name plus ": " if a header name was specified at Header construction time. The default value for maxlinelen is determined at header construction time. Optional splitchars is a string containing characters which should be given extra weight by the splitting algorithm during normal header wrapping. This is in very rough support of RFC 2822's `higher level syntactic breaks': split points preceded by a splitchar are preferred during line splitting, with the characters preferred in the order in which they appear in the string. Space and tab may be included in the string to indicate whether preference should be given to one over the other as a split point when other split chars do not appear in the line being split. Splitchars does not affect RFC 2047 encoded lines. Optional linesep is a string to be used to separate the lines of the value. The default value is the most useful for typical Python applications, but it can be set to \r\n to produce RFC-compliant line separators when needed. Nri@BrhriFrr%rz8header value appears to contain an embedded header: {!r})rjr__ValueFormatterr`r]rrmr3add_transitionr-feednewlineheader_encodingr0r7_str_embeded_headerr,rformat)ra splitcharsrRlinesep formatterrrrvrsr r!r3linesr@slinefwsvalues r"rlz Header.encode<sB   )J ?? J#DOZ$($9:GG ##9#| $ $OFG#!?dnnVAY&?&? !333#3w6H'H'H!00222$666y6,,...=4>>&*#=#=IFH%%''E 0r58W5555r2w///abb  8 8!!###*6NN4#8# :M#*,,,,!KKMME4D #e** 445CNN3w77775zzA~~!!### < '  $ $ & & &w''  ! !% ( ( :"$++16%==:: : r$c@g}d}g}|jD]W\}}||kr||!|/|t||f|g}|}X|r/|t||f||_dSry)rr1rnrp)rachunksrP last_chunkr r!s r"rjzHeader._normalizes  #| ' 'OFG,&&!!&))))+MM5::j#9#9<"HIII$X &  B MM5::j11<@ A A A r$)NNNNrrZ)NrZ)rNr) __name__ __module__ __qualname__rcrwr|r~r1rmrlrjrr$r"r r s'+.2-5-3-3-3-3^)))@""" !!!)*)*)*)*V444 OOOObr$r cDeZdZdZdZdZdZdZdZdZ dZ d Z d S) rc||_||_t||_||_g|_t ||_dSry)_maxlenr]r7_continuation_ws_len _splitchars_lines _Accumulator _current_line)ra headerlenmaxlenrTrs r"rcz_ValueFormatter.__init__sF /$'$8$8!% ))44r$c^|||jSry)rrpr)rars r"rz_ValueFormatter._strs# ||DK(((r$c6|tSry)rNLras r"rwz_ValueFormatter.__str__syy}}r$c|j}|dkr|jj|t|jdkrm|jr(|jdxxt |jz cc<n,|jt |j|jdS)N)rrrri) rr/pushr7 is_onlywsrrr1reset)ra end_of_lines r"rz_ValueFormatter.newlines(,,.. ) # # #D  #[ 1 1 t! " "Q & &!++-- < B3t'9#:#:: ""3t'9#:#:;;;   """""r$c<|jdddS)Nrr)rrrs r"rz_ValueFormatter.add_transitions! R(((((r$c$|j||||jdS|||} |d}n#t $rYdSwxYw|||| |}n#t $rYdSwxYw||j |j ||D]$}|j |j |z%dSNr)r _ascii_splitrheader_encode_lines _maxlengthsr/ IndexError _append_chunkrrrr]rr1)rarr r! encoded_lines first_line last_liner@s r"rz_ValueFormatter.feedsI  " *   c64+; < < < F 33FD>q@!RHH  Azz||""03A6"3q62::!E#1!A#6q9HHRL"$4$4 .2244 T%3a77LLNNN"""''T222*33A66I K  s4#566 7 7 7   $ $Y / / / / /9 2 1r$N) rrrrcrrwrrrrrrrr$r"rrs555))) # # #)))#=#=#=J;;; ***,00000r$rc\eZdZd fd ZdZd dZfdZdZdZd d Z d Z fd Z xZ S)rrcV||_tdSry)rr rc)ra initial_size __class__s r"rcz_Accumulator.__init__"s') r$c4|||fdSry)r1)rarr s r"rz_Accumulator.push&s S&M"""""r$c(||d}g||d<|Sryr)rarpoppeds r"rz_Accumulator.pop_from)s!abbQRR r$cx|dkrdStS)Nr)rr)rr r/rars r"r/z_Accumulator.pop.s/ ??  a  8ww{{}}r$c@td|D|jS)Nc3ZK|]&\}}t|t|zV'dSry)r7rrrs r" z'_Accumulator.__len__..4s7==93CHHSYY&======r$)sumrrs r"__len__z_Accumulator.__len__3s+=====%'' 'r$cJtd|DS)Nc3TK|]#\}}t||fV$dSryrorprs r"rz'_Accumulator.__str__..8sL!7!7$-C"-!1!13+!>!>!7!7!7!7!7!7r$rrs r"rwz_Accumulator.__str__7s6!7!715!7!7!788 8r$Nc*|g}||dd<d|_dSr)r)rastartvals r"rz_Accumulator.reset;s(  HQQQr$c`|jdko#| p t|Sr)rrr5rs r"rz_Accumulator.is_onlywsAs.!1$Jd(*Ic$ii6G6G6I6IJr$cDtSry)r rrs r"rz_Accumulator.part_countDsww   r$)rry) rrrrcrrr/rrwrrr __classcell__)rs@r"rr s###  '''888 KKK!!!!!!!!!r$r)NNr)3__doc__ __future__rrrfuture.builtinsrrrr r __all__rr9future.backportsrfuture.backports.emailrfuture.backports.email.errorsrfuture.backports.email.charset backportsr!r!future.backports.email.quoprimimerrrUrrnr=SPACE8ror^rr\rcompileVERBOSE IGNORECASE MULTILINEr+fcrerr r objectr rlistrrr$r"rso 21''''''&&&&&&99999999999999     """"""------::::::111111111111IHHHHHHH          '*  wwrz zBM!BL022rz#$$"*]++\\\~;? #    ,jjjjjVjjjZ}0}0}0}0}0f}0}0}0@%!%!%!%!%!4%!%!%!%!%!r$