Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#8252 closed enhancement (fixed)

Allow 8bit emails from trac

Reported by: petr.hroudny@… Owned by: Remy Blank
Priority: normal Milestone: 0.11.5
Component: general Version: none
Severity: normal Keywords:
Cc: petr.hroudny@… Branch:
Release Notes:
API Changes:
Internal Changes:

Description

#1754 introduced new config option

[notification]
mime_encoding = base64 | qp | none

in order to avoid unnecessary base64 encoding in emails from trac. However, it's still not possible to have trac output plain 8bit emails, since "none" only works with pure ASCII.

It's perfectly valid to generate 8-bit UTF-8 emails today, when the following MIME headers are used:

Content-Type: text/plain; charset=utf-8 
Content-Transfer-Encoding: 8bit

An example MUAs doing that are Thunderbird, Mutt, …

Thus another option for 8bit notifications is needed and I'd even say it should be the default these days.

The following addition into /trunk/trac/notification.py should do it:

297	        elif pref == '8bit':
298	            self._charset.header_encoding = SHORTEST
299	            self._charset.body_encoding = None
300	            self._charset.output_charset = 'utf-8'
301	            self._charset.input_codec = 'utf-8'
302	            self._charset.output_codec = 'utf-8'

Attachments (1)

8252-8bit-body-encoding-r8165.patch (4.4 KB ) - added by Remy Blank 16 years ago.
Patch against 0.11-stable using either 7bit or 8bit body encoding when mime_encoding = none.

Download all attachments as: .zip

Change History (5)

comment:1 by Remy Blank, 16 years ago

Milestone: 0.11.5
Owner: set to Remy Blank

comment:2 by petr.hroudny@…, 16 years ago

There is actually a major difference between Trac and Python. Option "none" in Python means no special encoding should be used and 8bit body is allowed, while in Trac this option only allows 7-bit ASCII messages.

Thus is might be perhaps better to redefine what "none" does in Trac and sync it with Python. The following lines need to be changed:

287	        from email.Charset import Charset, QP, BASE64, SHORTEST

303	        elif pref == 'none':
304	            self._charset.header_encoding = SHORTEST
305	            self._charset.body_encoding = None
306                 self._charset.output_charset = 'utf-8'
307	            self._charset.input_codec = 'utf-8'
308	            self._chaset.output_codec = 'utf-8'

And the following lines need to be removed:

459	        # sanity check
460	        if not self._charset.body_encoding:
461	            try:
462	                dummy = body.encode('ascii')
463	            except UnicodeDecodeError:
464	                raise TracError(_("Ticket contains non-ASCII chars. " \
465	                                  "Please change encoding setting"))

After the above changes, the option "none" could be used to send out properly formatted 8bit utf-8 emails.

by Remy Blank, 16 years ago

Patch against 0.11-stable using either 7bit or 8bit body encoding when mime_encoding = none.

in reply to:  2 comment:3 by Remy Blank, 16 years ago

Replying to petr.hroudny@…:

Thus is might be perhaps better to redefine what "none" does in Trac and sync it with Python.

This makes a lot of sense to me. Throwing an error when an e-mail requires 8bit encoding (which is quite often, as the ellipsis is used to obfuscate e-mail addresses) and [notification] mime_encoding = none is not very user friendly.

The patch above implements the suggestion, together with a test case.

Manu, could you please comment on the patch? Thanks!

comment:4 by Remy Blank, 16 years ago

Resolution: fixed
Status: newclosed

Patch applied in [8218].

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.