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/trac/notification/__pycache__/ |
Upload File : |
o �k�`� � @ s� d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z m Z mZ d dlm Z d dlmZ d dlmZ d dlmZmZmZ d dlmZmZ d d lmZmZmZmZmZ d d lm Z m!Z!m"Z"m#Z# d dl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, d dl-m.Z. d d l/m0Z0 d dl1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7m8Z8m9Z9m:Z: d dl;m<Z<m=Z= d dl>m?Z? g d�Z@dZAdZBe�CdejD�ZEdaFejGZHeHjIdd�ZJdd� ZKdd� ZLdd� ZMd@dd �ZNe�Cd!�ZOd"d#� ZPd$d%� ZQd&d'� ZRdAd(d)�ZSd*d+� ZTd,d-� ZUG d.d/� d/eV�ZWG d0d1� d1e �ZXG d2d3� d3ejG�ZYG d4d5� d5eV�ZZG d6d7� d7e �Z[G d8d9� d9e �Z\G d:d;� d;e �Z]G d<d=� d=e �Z^G d>d?� d?e �Z_dS )B� N)�policy)�BASE64�QP�SHORTEST�Charset)�Header)�Address)�EmailMessage)� formatdate� parseaddr�getaddresses)�Popen�PIPE)� BoolOption�ConfigurationError� IntOption�Option�OrderedExtensionsOption)� Component�ExtensionPoint� TracError� implements)� get_target_id�IEmailAddressResolver�IEmailDecorator�IEmailSender�INotificationDistributor�INotificationFormatter�INotificationSubscriber�NotificationSystem)�lazy)� close_fds)�time_now� to_utimestamp)�tag)�CRLF�exception_to_unicode�fix_eol� to_unicode)�_�tag_)�get_session_attribute)�AlwaysEmailSubscriber�EMAIL_LOOKALIKE_PATTERN�EmailDistributor�FromAuthorEmailDecorator�MAXHEADERLEN�RecipientMatcher�SendmailEmailSender�SessionEmailResolver�SmtpEmailSender�create_charset� create_header�create_message_id�create_mime_multipart�create_mime_text�get_message_addresses�get_from_author� set_header�L zJ[a-zA-Z0-9.'+_-]+@(?:[a-zA-Z0-9_-]+\.)+[a-zA-Z](?:[-a-zA-Z\d]*[a-zA-Z\d])?z=\?[^?]+\?[bq]\?[^?]+\?=i� )�max_line_lengthc C s~ t � }d|_d|_d|_d|_| �� }|dkrt|_t|_|S |dv r+t |_t |_|S |dkr7t |_d|_|S ttd| d���)a Create an appropriate email charset for the given encoding. Valid options are 'base64' for Base64 encoding, 'qp' for Quoted-Printable, and 'none' for no encoding, in which case emails will be sent as 7bit if the content is all ASCII, or 8bit otherwise. �utf-8�base64)�qp�quoted-printable�noneNz1Invalid email encoding setting: %(mime_encoding)s)� mime_encoding) r � input_charset�output_charset�input_codec�output_codec�lowerr �header_encoding� body_encodingr r r r) )rD �charset�pref� rN �8/usr/lib/python3/dist-packages/trac/notification/mail.pyr5 M s* ����r5 c C s� t t| �d }|dk rttd���d}t|ttf�r|\}}t|t�s(t|�}|s,|S d}t � |�sKz|�d�}W n tyC Y nw t |d|d�}|sXt |�|j�||d�}t|�}|rn|�dd��d d �}d||f }|S )aV Create an email Header. The `key` is always a string and will be converted to the appropriate `charset`. The `value` can either be a string or a two-element tuple where the first item is the name and the second item is the email address. See `set_header()` for a helper that sets a header directly on a message. � � zHeader length is too shortN�ascii)� maxlinelen�\z\\�"z\"z "%s" <%s>)r0 �lenr r) � isinstance�tuple�list�strr( �_mime_encoding_re�search�encode�UnicodeEncodeErrorr rH �replace)�key�valuerL � maxlength�email�header�tmprN rN rO r6 i s6 ��r6 c C s� t | t�r d| fg} g }| D ]G}t |t�r|�|� qt |t�r%d}|}nt |ttf�r1|\}}ntd| ��d|v rD|�dd�\}}n|}d}|�tt|pOd�||�� q|S )z�Create address header instance to pass to `set_header`. The `addresses` is a list or an iterable of addresses. The item can either be `str`, a `(name, address)` tuple or a `(None, address)`. NzUnrecognized item %r�@� � ) rW rZ r �appendrY rX � ValueError�rsplit�_replace_encoded_words)� addresses�l�item�name�addr�username�domainrN rN rO �create_address_header� s&