Code

#18861 closed Bug (fixed)

The test email backend (locmem) should perform more validation of messages

Reported by: brutasse Owned by: nobody
Component: Core (Mail) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently the locmem email backend only stores EmailMessage instances on mail.outbox, and does not perform as much validation as other backends.

In particular, calling .message() on an EmailMessage instance creates a SafeMIMEText object which forbids multiline headers. All email backends call .message() except for the locmem backend. This is a opportunity for deployment surprises where sending an email would work during the tests but not in production if the subject is constructed using a template that has an EOL marker at the end of the file.

The attached patch naively calls .message() on each outgoing message to trigger this validation. This should be backwards-compatible since that error would be raised anyways when sending emails with a proper backend.

An alternative solution to this issue (email subjects ending with a newline) could be to strip all headers but this is a more intrusive change.

Attachments (2)

18861.patch (1.4 KB) - added by brutasse 20 months ago.
18861-2.diff (1.3 KB) - added by claudep 20 months ago.
Move test in LocmemBackendTests

Download all attachments as: .zip

Change History (6)

Changed 20 months ago by brutasse

comment:1 Changed 20 months ago by brutasse

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 20 months ago by aaugustin

  • Triage Stage changed from Unreviewed to Accepted

Changed 20 months ago by claudep

Move test in LocmemBackendTests

comment:3 Changed 20 months ago by claudep

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 19 months ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 8599f64e54adfb32ee6550ed7a6ec9944034d978:

Fixed #18861 -- Triggered message validation with locmem email backend

Thanks Bruno Renié for the report and the initial patch.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.