Closed Bug 1657496 Opened 4 years ago Closed 3 years ago

Bugzilla sets email content-type incorrectly

Categories

(Bugzilla :: Email Notifications, defect)

5.0.6
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: emmanuel, Assigned: justdave)

References

Details

Attachments

(4 files)

I'm just going to quote justdave in bmo #1855962:

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.

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)

And as I also said on that bug (on brc actually), I'm approving backporting the fix for this to all supported branches, since it actually breaks email notifications if the site updates its Perl modules.

Assignee: email-notifications → justdave
Attachment #9169527 - Flags: review?(emmanuel)
Attachment #9169528 - Flags: review?(emmanuel)
Attachment #9169529 - Flags: review?(emmanuel)

Comment on attachment 9169528 [details] [diff] [review]
patch against bugzilla/5.2 and bugzilla/5.0

Tested and found to correct the problem. I'll be folding this in the Fedora package in the coming days.

Attachment #9169528 - Flags: review?(emmanuel) → review+

Comment on attachment 9169529 [details] [diff] [review]
patch against bugzilla/4.4

This is the same patch as for 5.0/5.2 but with different context. I'm comfortable giving a + on it without testing it.

Attachment #9169529 - Flags: review?(emmanuel) → review+

Comment on attachment 9169527 [details] [diff] [review]
patch against harmony

I'm unable to install the harmony branch of bugzilla and, thus, unable to review this patch.

Attachment #9169527 - Flags: review?(emmanuel)
Attachment #9169527 - Flags: review?(mozilla)
Attachment #9169527 - Flags: review?(mozilla) → review+

(bugzilla)
[4.4 c3a6c619b] Bug 1657496: correctly handle MIME type on single-part email. r=eseyman, a=justdave
1 file changed, 4 insertions(+), 3 deletions(-)

[5.0 4f4afbd8d] Bug 1657496: correctly handle MIME type on single-part email. r=eseyman, a=justdave
1 file changed, 4 insertions(+), 4 deletions(-)

[5.2 6765ab047] Bug 1657496: correctly handle MIME type on single-part email. r=eseyman, a=justdave
1 file changed, 4 insertions(+), 4 deletions(-)

(harmony)
[main db9cc834d] Bug 1657496: correctly handle MIME type on single-part email. r=cybershadow, a=justdave
1 file changed, 3 insertions(+), 4 deletions(-)

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED

We should commit this on 5.1 as well since we intend to keep that usable until harmony has feature parity with it.

Flags: needinfo?(justdave)

GitHub PR for 5.1 provided by :alialnu

Flags: needinfo?(justdave)

[master f82dde7] Bug 1657496: correctly handle MIME type on single-part email. r=justdave
1 changed file with 4 additions and 4 deletions.

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

Attachment

General

Created:
Updated:
Size: