Edgewall Software
Modify

Opened 3 years ago

Closed 3 years ago

#13340 closed defect (cantfix)

Too long line in part with `Content-Transfer-Encoding: base64` in notification mail

Reported by: Jun Omae Owned by: Jun Omae
Priority: normal Milestone:
Component: notification Version: 1.5.2
Severity: normal Keywords:
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

unit-test with r17497 fails on my environment.

======================================================================
FAIL: test_mimebody_b64 (trac.ticket.tests.notification.NotificationTestCase)
MIME Base64/utf-8 encoding
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/ticket/tests/notification.py", line 721, in test_mimebody_b64
    ticket, True)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/tests/notification.py", line 848, in _validate_mimebody
    self.assertTrue(len(line) <= MAXBODYWIDTH)
AssertionError: False is not true

----------------------------------------------------------------------

I applied the following changes to investigate the failure.

  • trac/ticket/tests/notification.py

    diff --git a/trac/ticket/tests/notification.py b/trac/ticket/tests/notification.py
    index dae1da8f9..0cc0b64fc 100644
    a b class NotificationTestCase(unittest.TestCase):  
    844844        self.assertEqual(mime_charset, charset)
    845845        self.assertEqual(headers['Content-Transfer-Encoding'], mime_name)
    846846        # checks the width of each body line
    847         for line in body.splitlines():
    848             self.assertTrue(len(line) <= MAXBODYWIDTH)
     847        for idx, line in enumerate(body.splitlines()):
     848            self.assertTrue(len(line) <= MAXBODYWIDTH,
     849                            'Line %d too long (%d > %d, %r)' %
     850                            (idx + 1, len(line), MAXBODYWIDTH, line))
    849851        # attempts to decode the body, following the specified MIME encoding
    850852        # and charset
    851853        try:

After the changes, I get the following message. Body encoded with base64 has line exceeded 76 characters. That's weird.

======================================================================
FAIL: test_mimebody_b64 (trac.ticket.tests.notification.NotificationTestCase)
MIME Base64/utf-8 encoding
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jun66j5/src/tracdev/git/trac/ticket/tests/notification.py", line 721, in test_mimebody_b64
    ticket, True)
  File "/home/jun66j5/src/tracdev/git/trac/ticket/tests/notification.py", line 850, in _validate_mimebody
    (idx + 1, len(line), MAXBODYWIDTH, line))
AssertionError: False is not true : Line 1 too long (80 > 76, 'IzE6IFRoaXMgaXMgYSBsb25nIGVub3VnaCBzdW1tYXJ5IHRvIGNhdXNlIFRyYWMgdG8gZ2VuZXJhdA==')

----------------------------------------------------------------------

Attachments (0)

Change History (1)

comment:1 by Jun Omae, 3 years ago

Milestone: 1.5.3
Resolution: cantfix
Status: assignedclosed

It is able to reproduce with small code:

from email.message import EmailMessage
m = EmailMessage()
m.set_content('あ' * 20, subtype='plain', cte='base64')
print(m)

Output:

Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
MIME-Version: 1.0

44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC44GC4w==
gYIK

I noticed it occurs only with Python 3.5.2 (Ubuntu 16.04LTS). It doesn't occur with Python 3.6.12, 3.7.9, 3.8.7, 3.9.1 and 3.10.0a3.

Investigating, I found https://bugs.python.org/issue28047 related to the issue and it has been fixed in https://hg.python.org/cpython/rev/99db6a25444b (Python 3.5.3). I confirmed fixed with Python 3.5.4 on Windows.

Going to close as cantfix….

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Jun Omae.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Jun Omae 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.