https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/mail.cpython-310.pyc
o

�]LbXD�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
mZddlmZmZddlmZmZmZmZmZddlmZmZmZejrqddlmZmZmZm Z e!eeee f�sqJ�Gd	d
�d
e
j"�Z#Gdd�de
j"�Z$d
d�Z%dd�Z&dd�Z'dd�Z(dd�Z)d;dd�Z*d;dd�Z+dd�Z,dd�Z-d<d!d"�Z.d#d$�Z/d%d&�Z0d'd(�Z1d=d)d*�Z2d;d+d,�Z3d=d-d.�Z4d=d/d0�Z5d=d1d2�Z6ej7r�ej8j9Z:d3d4�Z;d5d6�Z<nej8j:Z:d7d4�Z;d8d6�Z<d9d:�Z=dS)>�)�absolute_importN�)�_)�getattr�open)�encoding�error�pycompat�sslutil�util)�procutil�
stringutil�urlutil)�Any�List�Tuple�Unionc@s$eZdZdZddd�Zddd�ZdS)	�STARTTLSz�Derived class to verify the peer certificate for STARTTLS.

    This class allows to pass any keyword arguments to SSL socket creation.
    NcKs$tjj|fi|��||_||_dS�N)�smtplib�SMTP�__init__�_ui�_host)�self�ui�host�kwargs�r�0/usr/lib/python3/dist-packages/mercurial/mail.pyr5s
zSTARTTLS.__init__cCsx|�d�sd}t�|��|�d�\}}|dkr8tj|j|||j|jd�|_|j�	d�|_
d|_d|_i|_
d|_||fS)N�starttlss*STARTTLS extension not supported by serverr���r�serverhostname�rbr)�has_extnr�
SMTPException�docmdr
�
wrapsocket�sockrr�makefile�file�	helo_resp�	ehlo_resp�esmtp_features�
does_esmtp)r�keyfile�certfile�msg�resp�replyrrrr :s$

�zSTARTTLS.starttlsr)NN)�__name__�
__module__�__qualname__�__doc__rr rrrrr/s
rc@s"eZdZdZddd�Zdd�ZdS)�SMTPSz�Derived class to verify the peer certificate for SMTPS.

    This class allows to pass any keyword arguments to SSL socket creation.
    NcKs8||_||_tjj|fi|��||_tj|_||_dSr)	r0r1rrrr�
SMTP_SSL_PORT�default_portr)rrr0r1rrrrrrUs
zSMTPS.__init__cCs\|jdkr|j�d||ff�t�||f|�}tj||j|j|j|j	d�}|�
d�|_|S)Nrsconnect: %r
r"r$)�
debuglevelr�debug�socket�create_connectionr
r(r0r1rr*r+)rr�port�timeout�
new_socketrrr�_get_socket]s
�zSMTPS._get_socket)NNN)r5r6r7r8rrCrrrrr9Os
r9cCs0z
ddl}t|dd�WdStyYdSw)z9Returns true iff Python has TLS support, false otherwise.rN�HAS_TLSFT)�sslr�ImportError)rErrr�	_pyhastlsls�rGc

s�|�dd�}|�dd�}|dkpt�|�}|dk}|s|r't�s't�td���|�dd�}|s6t�td���|rG|�td	��t|||d
��n|rQt	|||d
��nt
j|d��|r\d}nd
}t�
|�dd|��}|�td�||f��j||d�|r�|�td�����������|s�|r�|�td��t��j�z	t|�||�Wnt
jy�}zt�t�|���d}~ww�fdd�}	|	S)z;build an smtp connection and return a function to send mail�smtpslocal_hostnamestlssstarttlsssmtpss/can't use TLS: Python SSL support not installed�hosts+smtp.host not configured - cannot send mails(using smtps)
)�local_hostnamer)rJi��sports$sending mail: smtp host %s, port %d
)rr@s(using starttls)
s(verifying remote certificate)
Nc
s|z��|||�WStjy)}zdd�|j��D�}t�dd�|���d}~wtjy=}zt�t	�
|���d}~ww)NcSsg|]}|d�qS)rr)�.0�rrrr�
<listcomp>�sz'_smtp.<locals>.send.<locals>.<listcomp>�
)�sendmailr�SMTPRecipientsRefused�
recipients�valuesr�Abort�joinr&r
�forcebytestr)�senderrRr2�inst��srr�send�s���z_smtp.<locals>.send)�configr
�	parseboolrGrrTr�noter9rrrr�getport�connect�ehlor r
�validatesocketr)�_smtp_loginr&rV)
rrJ�tlsr �smtps�mailhost�defaultport�mailportrXr[rrYr�_smtpxsJ��	ricCs�|�dd�}|�dd�}|r#|rt�|�}n
|��}|dur#t�|�}|r=|r?|�td�|�t�|�}|�||�dSdSdS)azA hook for the keyring extension to perform the actual SMTP login.

    An already connected SMTP object of the proper type is provided, based on
    the current configuration.  The host and port to which the connection was
    established are provided for accessibility, since the SMTP object doesn't
    provide an accessor.  ``smtplib.SMTPException`` is raised on error.
    rHsusernamespasswordNs&(authenticating to mail server as %s)
)r\r�strfromlocal�getpassr^r�login)r�smtprfrh�username�passwordrrrrc�s

�rcc	Cs�|�dd�}dd�}d|||�d�t||��f}|�td�|�t�|d�}|�t�	|��|�
�}|rKt�d	t
j�t�|�d
�t�|�f��dS)zsend mail using sendmail.�email�methodcSst�t�t�|���Sr)r�
shellquoter
�emailr�
strtolocal)�xrrr�stremail�sz_sendmail.<locals>.stremails%s -f %s %s� ssending mail: %s
�wbs%s %srN)r\rU�mapr^rr�popen�writer�tonativeeol�closerrT�os�path�basename�
shellsplit�explainexit)	rrWrRr2�programrv�cmdline�fp�retrrr�	_sendmail�s(�����r�cCsrt|d��*}t�dt���}|�dt�|�t�|�f�|�|�|�d�Wd�dS1s2wYdS)zwrite mails to mboxsab+z%a %b %d %H:%M:%S %YsFrom %s %s
s

N)r�time�strftime�	localtimer{rrt)�mboxrWrRr2r��daterrr�_mbox�s��
"�r�csB�rt�d����fdd�S��dd�dkrt��S�fdd�S)znmake a mail connection. return a function to send mail.
    call as sendmail(sender, list-of-recipients, msg).rxc�t�|||�Sr)r��rZrM�m�r�rr�<lambda>��zconnect.<locals>.<lambda>rprqrHcr�r)r�r�)rrrr��r�)rr}r\ri)rr�r)r�rrr`�sr`cCst||d�}||||�S)Nr�)r`)rrWrRr2r�r[rrrrP�srPcCsR|�dd�}|dkr|�dd�st�td���dSt�|�s't�td�|��dS)z=determine if we have enough config data to try sending email.rprqrHrIs>smtp specified as email transport, but no smtp host configureds0%r specified as email transport, but not in PATHN)r\rrTrr�findexe)r�methodrrr�validateconfig�s���

��r�cCs:tj�|�j��}|�d�r|�d�sd|dd�S|S)� �isoziso-�N)rs�charset�Charset�
input_charset�lower�
startswith)�csrrr�
codec2ianasr��plainFc	Csnddt�tj�t�tj�g}|rdg}|D]}z|�|�t||t|��WSty0Yqwt||d�S)a2Return MIME message suitable for a patch.
    Charset will be detected by first trying to decode as us-ascii, then utf-8,
    and finally the global encodings. If all those fail, fall back to
    ISO-8859-1, an encoding with that allows all byte sequences.
    Transfer encodings will be used if necessary.�us-ascii�utf-8z
iso-8859-1)r	�sysstrr�fallbackencoding�decode�
mimetextqpr��UnicodeDecodeError)rZ�subtype�displayr�r�rrr�
mimetextpatchs	

�
�r�cCs\tj�|�}tj��}|�d|�|��D]}t|�dkr%tjj|_	nq|�
||�|S)z[Return MIME message.
    Quoted-printable transfer encoding will be used if necessary.
    ztext/i�)rsr�r��message�Message�set_type�
splitlines�len�QP�
body_encoding�set_payload)�bodyr�r�r�r2�linerrrr�3s

�r�cCsbdd�|�dd�D�}t�tj���t�tj���dg}|D]}||vr)|�|�qdd�|D�S)z;Obtains charsets to send mail parts not containing patches.cSsg|]	}t�|����qSr)r	r�r��rLr�rrrrNPs��z_charsets.<locals>.<listcomp>rpscharsetsr�cSsg|]	}|�d�s|�qS)�ascii)�endswithr�rrrrN\s)�
configlistr	r�rr�r��append)r�charsets�	fallbacksr�rrr�	_charsetsMs
��
�r�cCsJ|pt|�}t|t�s?|D])}z
|�|�|fWSty"Yq
ty6|�td�t�	|��Yq
w|�dd�dfSz
|�
d�W|dfSty�tjtj
fD]H}t�|�}z|�
|�}Wn	tymYqVw|D]-}z|�|�|fWYSty�Yqpty�|�td�t�	|��YqpwqVY|dfSw)aReturns (converted) string, charset tuple.
    Finds out best charset by cycling through sendcharsets in descending
    order. Tries both encoding and fallbackencoding for input. Only as
    last resort send as is in fake ascii.
    Caveat: Do not use for mail parts containing patches!s!ignoring invalid sendcharset: %s
r��backslashreplacer�)r��
isinstance�bytes�encode�UnicodeEncodeError�LookupError�warnrr	�sysbytesr�r�rr�r�)rrZr��sendcharsets�ocs�ics�urrr�_encode_sT
����
�������r�cCs0|st|||�\}}tj�||���St�|�S)z4Returns RFC-2047 compliant header from given string.)r�rs�header�Headerr�rrj�rrZr�r�r�rrr�
headencode�s
r�cCs�t�|�}t|||�}z |�d�\}}|�d�|�t�tj���d�}d||f}Wn0ty;t	�
td�|��ty[z|�d�WntyXt	�
td�|��wYnwt
j�|t�|�f�S)N�@r��idnas%s@%ssinvalid email address: %ssinvalid local address: %s)rrtr��splitr�r	r�r�r�rrTr�
ValueErrorrs�utils�
formataddrrj)r�name�addrr��acc�domrrr�_addressencode�s$

���r�cCs:|s|st�|p	d�Stj�t�|��\}}t||||�S)z-Turns address into RFC-2047 compliant header.�)rrjrsr��	parseaddrr�)r�addressr�r�r�r�rrr�
addressencode�sr�c
Cs�g}|D]}t|t�sJd|��|�t�|��q|r#dd�|D�Sg}tj�|�D]\}}|s3|r?t||||�}	|�|	�q+|S)z�Turns a list of addresses into a list of RFC-2047 compliant headers.
    A single element of input list may contain multiple addresses, but output
    always has one address per itemz%r unexpectedly not a bytestrcSsg|]
}|��r|���qSr)�strip)rL�arrrrN�sz"addrlistencode.<locals>.<listcomp>)	r�r�r�rrjrsr��getaddressesr�)
r�addrsr�r��straddrsr��resultr�r�rMrrr�addrlistencode�s
�r�cCs$d}|st|||�\}}t|d|�S)zgcreates mime text object, encodes it if needed, and sets
    charset and transfer-encoding accordingly.r�r�)r�r�r�rrr�
mimeencode�sr�cCs@tj��}tj|ddtd�d�}z
|�|�W|��S|��w)Nr��surrogateescape�
)r�errors�newline)rs�parser�Parser�io�
TextIOWrapper�chr�parse�detach�r��eprrrr��s
�
r�cC�tj��}|�|�Sr)rsr��BytesParser�
parsebytes��datar�rrrr���

r�cCr�r)rsr�r�r�r�rrrr��r�cCr�r)rsr�r��parsestrr�rrrr��r�c
Cs�g}tj�|�D]G\}}|dur&z
|�|�|��Wqttfy%Ynwt|td��r3|�|�qz
|�|�d��WqtyFYnw|�|�d��qt	�
d�|��S)zDecodes RFC-2047 headerN�zUTF-8z
ISO-8859-1r�)rsr��
decode_headerr�r�r�r�r��typer�
unitolocalrU)rZ�uparts�partr�rrr�
headdecode�s(�
�rr)r�F)NF)>�
__future__rrs�
email.charset�email.generator�email.header�
email.message�email.parserr�r~rr>r��i18nrr	rrr�rrr
rr�rr
r�
TYPE_CHECKING�typingrrrr�allrrr9rGrircr�r�r`rPr�r�r�r�r�r�r�r�r�r�r��ispy3�	generator�BytesGenerator�	Generatorr�r�rrrrr�<module>s^ 4



3



	




https://t.me/RX1948 - 2025