Bug 1855962 - bugzilla can't send non-html email
Summary: bugzilla can't send non-html email
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: bugzilla
Version: 32
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Emmanuel Seyman
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-07-11 10:23 UTC by Sjoerd Mullender
Modified: 2020-10-29 01:12 UTC (History)
5 users (show)

Fixed In Version: bugzilla-5.0.6-9.fc33 bugzilla-5.0.6-6.fc32 bugzilla-5.0.6-4.fc31 bugzilla-5.0.6-10.fc33 bugzilla-5.0.6-7.fc32 bugzilla-5.0.6-5.fc31
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-29 01:05:36 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
the patch (553 bytes, patch)
2020-07-11 10:23 UTC, Sjoerd Mullender
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Mozilla Foundation 1657496 0 -- NEW Bugzilla sets email content-type incorrectly 2020-10-22 20:25:27 UTC

Description Sjoerd Mullender 2020-07-11 10:23:36 UTC
Created attachment 1700684 [details]
the patch

Description of problem:

Since the update to packages perl-Email-MIME-1.949-1.fc31.noarch and perl-Email-MIME-ContentType-1.024-1.fc31.noarch on Fedora 31, bugzilla can't send non-html (simple text/plain) emails anymore.
The reason seems to be a tighter control of how the method content_type_set() is to be used.  When sending non-html email, bugzilla uses a call
$email->content_type_set($parts[0]->content_type);
(BugMail.pm, line 499) where the given content_type contains the string 'text/plain; charset=UTF-8'.  The content_type_set method splits on the / and wants the second part to be a correct MIME subtype.  But clearly it isn't since it also contains a charset attribute.
The solution (what works for me) is to replace this call with two calls:
$email->content_type_set('text/plain');
$email->charset_set($use_utf8 ? 'UTF-8' : 'iso-8859-1');

Note that the code being executed is only used in case there is a single part to be sent (i.e. not html which uses the other branch for multipart messages), and so is definitely text/plain.

This problem occurs both in Fedora 31 and 32.

Version-Release number of selected component (if applicable):
bugzilla-5.0.6-3.fc31.noarch
perl-Email-MIME-1.949-1.fc31.noarch
perl-Email-MIME-ContentType-1.024-1.fc31.noarch


How reproducible:
100%

Steps to Reproduce:
1.configure bugzilla to send plain text emails (Administration -> Default Parameters).
2.trigger bugzilla to send an email by e.g. adding or changing a bug.
3.

Actual results:
A page saying:
Invalid Content-Type 'subtype' parameter at Bugzilla/BugMail.pm line 499.
and no email being sent.
(during experimentation I added code to the report function to tell me the content of this invalid subtype; it turned out to be 'plain; charset=UTF-8')

Expected results:
email being sent.

Additional info:

Comment 1 Dave Miller 2020-08-05 12:39:56 UTC
From the discussion on upstream Bugzilla's IRC:

Bugzilla's code was broken from the beginning, but a bug in Email::MIME prior to 1.949 was accidentally making our code work.  1.949 fixed that bug, and exposed the error in our code.

The proposed patch on this bug isn't quite correct, though.

What Bugzilla's existing code is trying to do:
- if the email has only one part (which happens in plaintext email), it tries to copy the content type from that part to the email itself
- it does this by grabbing the Content-type header from that part and passing it to content_type_set
- this is broken because it's grabbing the entire Content-type header from that part, and passing it to a function designed explicitly to only set the type itself and not the other attributes.

It works in Email::MIME 1.946 because when generating the Content-type header it takes the type and subtype and puts them into the Content-type header unchecked, and then starts adding attributes to it.  The attributes we passed as part of the subtype, since they weren't checked, actually made it to the header.  In 1.949, Email::MIME started using the build_content_type function from Email::MIME::Header, which actually checks that the subtype is valid.

The code path at https://github.com/bugzilla/bugzilla/blob/5.0/Bugzilla/BugMail.pm#L498 shouldn't be necessary at all.  Email::MIME, when generating an email which has only one part, already copies the Content-type header from that one and only part to the email itself, which you can see at https://metacpan.org/release/Email-MIME/source/lib/Email/MIME.pm#L789 and in Bugzilla's earliest-supported version of Email::MIME at https://metacpan.org/source/RJBS/Email-MIME-1.904/lib/Email/MIME.pm#L658

So the correct fix is basically to remove that line of code (and the if block only needs to act if there are multiple parts)

This should be re-filed upstream, and in my opinion the fix is worth backporting to all supported branches, since email basically stops working if you're set for sending text email.

Comment 2 Fedora Update System 2020-09-29 20:53:07 UTC
FEDORA-2020-ed56800b3e has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-ed56800b3e

Comment 3 Fedora Update System 2020-09-29 20:53:08 UTC
FEDORA-2020-53cdcb90d8 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-53cdcb90d8

Comment 4 Fedora Update System 2020-09-30 01:12:05 UTC
FEDORA-2020-ed56800b3e has been pushed to the Fedora 33 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-ed56800b3e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-ed56800b3e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 5 Fedora Update System 2020-09-30 01:21:51 UTC
FEDORA-2020-707592630e has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-707592630e`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-707592630e

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 6 Fedora Update System 2020-09-30 01:22:07 UTC
FEDORA-2020-53cdcb90d8 has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-53cdcb90d8`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-53cdcb90d8

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 7 Fedora Update System 2020-10-04 00:15:29 UTC
FEDORA-2020-ed56800b3e has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 8 Fedora Update System 2020-10-07 20:36:42 UTC
FEDORA-2020-53cdcb90d8 has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 9 Fedora Update System 2020-10-07 20:45:23 UTC
FEDORA-2020-707592630e has been pushed to the Fedora 31 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Sjoerd Mullender 2020-10-16 07:29:08 UTC
The Fedora 32 version of the bugzilla (bugzilla-5.0.6-6.fc32.noarch) does not contain the patch for this bug.
The file /usr/share/bugzilla/Bugzilla/BugMail.pm has not changed since the previous version.

Comment 11 Sjoerd Mullender 2020-10-16 07:36:20 UTC
I see that the patch is included in the source RPM, but the patch is not applied by the .spec file.

Comment 12 Sjoerd Mullender 2020-10-20 11:16:16 UTC
Reopening in the hope someone sees my comments.

Comment 13 Fedora Update System 2020-10-20 21:15:53 UTC
FEDORA-2020-2db60d8180 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2020-2db60d8180

Comment 14 Fedora Update System 2020-10-20 21:15:56 UTC
FEDORA-2020-d933f06bdb has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2020-d933f06bdb

Comment 15 Fedora Update System 2020-10-20 21:15:59 UTC
FEDORA-2020-336033183b has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2020-336033183b

Comment 16 Fedora Update System 2020-10-21 15:33:24 UTC
FEDORA-2020-2db60d8180 has been pushed to the Fedora 32 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-2db60d8180`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-2db60d8180

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 17 Fedora Update System 2020-10-21 15:39:01 UTC
FEDORA-2020-d933f06bdb has been pushed to the Fedora 31 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-d933f06bdb`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-d933f06bdb

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 18 Fedora Update System 2020-10-21 21:32:16 UTC
FEDORA-2020-336033183b has been pushed to the Fedora 33 testing repository.
In short time you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2020-336033183b`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2020-336033183b

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 19 Fedora Update System 2020-10-29 01:05:36 UTC
FEDORA-2020-336033183b has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 20 Fedora Update System 2020-10-29 01:12:37 UTC
FEDORA-2020-2db60d8180 has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 21 Fedora Update System 2020-10-29 01:12:41 UTC
FEDORA-2020-d933f06bdb has been pushed to the Fedora 31 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.