B /g^)@s:ddlZddlZddlZddlZddlmZGdddZeZd%ddZe ded d Z xd D]Z e e e qhWd d Z x d D]Ze dee qWddZe deddZddZddZddZd&ddZeeed'd d!Zeejjed(d#d$Zx eeefD]Zeeeq WdS))N) quoprimimec@s<eZdZddZddZddZddZd d Zd d Zd S)ContentManagercCsi|_i|_dS)N) get_handlers set_handlers)selfr,/usr/lib64/python3.7/email/contentmanager.py__init__ szContentManager.__init__cCs||j|<dS)N)r)rkeyhandlerrrradd_get_handler szContentManager.add_get_handlercOs||}||jkr(|j||f||S|}||jkrP|j||f||Sd|jkrp|jd|f||St|dS)N)Zget_content_typerget_content_maintypeKeyError)rmsgargskwZ content_typemaintyperrr get_contents   zContentManager.get_contentcCs||j|<dS)N)r)rZtypekeyr rrradd_set_handlerszContentManager.add_set_handlercOs>|dkrtd|||}||||f||dS)NZ multipartz"set_content not valid on multipart)r TypeError_find_set_handlerZ clear_content)rrobjrrr rrr set_contents   zContentManager.set_contentc Csd}xt|jD]}||jkr(|j|S|j}t|dd}|rLd||fn|}|dkr\|}||jkrp|j|S||jkr|j|S|j}||jkr|j|SqWd|jkr|jdSt|dS)N __module__r .)type__mro__r __qualname__getattrjoin__name__r) rrrZfull_path_for_errortypZqnamemodname full_pathnamerrrr's&          z ContentManager._find_set_handlerN) r!rrr r rrrrrrrrrs   rreplacecCs&|jdd}|dd}|j||dS)NT)decodecharsetASCII)errors) get_payloadZ get_paramr')rr*Zcontentr(rrrget_text_content@s  r,textcCs |jddS)NT)r')r+)rrrrget_non_text_contentGsr.zaudio image video applicationcCs |dS)Nr)r+)rrrrget_message_contentMsr/zrfc822 external-bodyzmessage/cCst|dS)Nr)bytesr+)rrrr%get_and_fixup_unknown_message_contentSsr1messagec sd||f|d<|rt|dds<|jfdd|D}y,x&|D]}|jrX|jd|||j<qDWWn@tjjk r}ztd |j |jd|Wdd}~XYnXdS) N/z Content-Typerr%csg|]}j|gqSr)Zheader_factoryZheader_source_parse).0header)mprr dsz _prepare_set..zInvalid header: {})policy) r hasattrr8Zdefectsr%emailr*Z HeaderDefect ValueErrorformatZfold)rrsubtypeheadersr5excr)r6r _prepare_set_s   r@cCs||dkr|dk rd}|dk r$||d<|dk r>|jd|ddd|dk rN||d<|dk rxx |D]\}}|||q`WdS)NZ attachmentzContent-DispositionfilenameT)r5r&z Content-ID) set_paramitems)r dispositionrAcidparamsr valuerrr _finalize_setpsrHcCsZg}|dd}x>tdt||D]*}||||}|t|dq"Wd|S)Nrasciir )rangelenappendbinascii b2a_base64r'r )datamax_line_lengthZ encoded_linesZunencoded_bytes_per_lineiZthislinerrr_encode_base64s  rTc s|||}|jdfdd}dd}|dkryd||dfStk r\YnX|jdkrtdd |D|jkrd||dd fS||dd }t |d |j}t |} t |t | krd }nd}t |d kr||fS|dkr ||d} nj|dkr&||dd } nN|dkrJt ||d |j} n*|d krft |||j} ntd||| fS)NrKcs|S)N)r )lines)lineseprr embedded_bodyz#_encode_text..embedded_bodycSsd|dS)N )r )rUrrr normal_bodyrXz!_encode_text..normal_body7bit8bitcss|]}t|VqdS)N)rM)r4xrrr sz_encode_text..surrogateescape zlatin-1base64zquoted-printablez$Unknown content transfer encoding {})encode splitlinesrVr'UnicodeDecodeErrorZcte_typemaxrRrZ body_encoderOrPrMrTr;r<) stringr(cter8rUrWrZZsniffZsniff_qpZ sniff_base64rQr)rVr _encode_texts@           rhplainutf-8c Csdt|d|| t||||j\}} || |jdtjj||dd||d<t |||||dS)Nr-r(T)r&zContent-Transfer-Encoding) r@rhr8 set_payloadrBr:r(ZALIASESgetrH) rrfr=r(rgrDrArErFr>Zpayloadrrrset_text_contents rmrfc822c Cs|dkrtd|dkr@|dkr.td||dkr:dn|}n0|dkrd|dkr^td |d }n |dkrpd }t|d ||||g||d <t|||||dS) Npartialz4message/partial is not supported for Message objectsrn)Nr[r\binaryz*message/rfc822 parts do not support cte={}r\z external-body)Nr[z1message/external-body parts do not support cte={}r[r2zContent-Transfer-Encoding)r;r<r@rkrH) rr2r=rgrDrArErFr>rrrset_message_contents$   rqrac Cst|||| |dkr(t||jjd}nN|dkrNtj|dddd}|d}n(|dkrb|dn|d krv|dd }||||d <t |||||dS) Nra)rRzquoted-printableFT)istextr5Z quotetabsrKr[)r\rpr_zContent-Transfer-Encoding) r@rTr8rRrOZb2a_qpr'rbrkrH) rrQrr=rgrDrArErFr>rrrset_bytes_contents    rs)r&)rirjNNNNNN)rnNNNNNN)raNNNNN)rOZ email.charsetr:Z email.messageZ email.errorsrrZraw_data_managerr,r r.splitrr/r=r1r@rHrTrhrmrstrrqr2ZMessagersr0 bytearray memoryviewr"rrrrsD 6   '