Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-66045

Mime types for email attachments are in uppercase and PDFs fail to be previewed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Medium
    • None
    • 7.4.1
    • Email notifications
    • None

    Description

      Summary

      When creating tickets/comments in JIRA via email, if an attachment is added to the email processed by JIRA, this attachment is added to the created/commented ticket as well.

      For most attachment types, this is not a problem, but PDFs are failing to be previewed in the issue when added this way when using a Gmail account (not tested in others) as Email Server accessed by JIRA (not the user's source email).

      This is happening because JIRA registered the ‘mime type’ for attachments in the ‘fileattachment’ table. All attachments added by email have a mime type in uppercase for some reason.

      For most attachments, this is not a problem, but JIRA is not able to preview PDFs with uppercase in mime type.

      Environment

      This was only tested with Gmail in external emails.

      Steps to Reproduce

      1. Create a test Gmail account
      2. Create an Email Server connecting to the Gmail account and a handler to process the emails and create comments
      3. Send an email message with a PDF attached to the Gmail account to either create a new ticket or comment and existing one
      4. Navigate to the issue and click the PDF attachment

      Expected Results

      The issue created/commented has a PDF attachment that when clicked previews the PDF in the browser (doesn’t download it).

      Actual Results

      The PDF attachment is not identified as PDF, cannot be previewed and when clicked causes the file to be downloaded, not previewed.

      Notes

      Here’s is the difference between a PDF added via email and added in the UI:

      jira=# select * from fileattachment where issueid in (select jiraissue.id from jiraissue join project on jiraissue.project = project.id where project.pkey = 'TP' and jiraissue.issuenum = 1);
         id | issueid | mimetype | filename | created | filesize | author | zip | thumbnailable 
      ------+---------+-----------------+--------------------------------+----------------------------+----------+----------+-----+---------------
      10004 |   10000 | application/pdf | pdf_added_in_ui.pdf            | 2016-01-27 19:45:09.801-02 |    20597 | sysadmin |     |             0
      10002 |   10000 | APPLICATION/PDF | pdf-attached_email.pdf         | 2016-01-27 19:30:41.117-02 |    20597 | admin    |     |             0
      

      The first one can be previewed when clicked, while the second one when clicked in the issue is downloaded.

      Also, if you take a PDF that is working (can be preview and its mime type is in lowercase in the database) and change the mime type to uppercase and re-index JIRA, this PDF will have the same problem as the ones added by email. This shows that indeed the uppercase is what prevents these attachments from being previewed.

      Workaround

      None so far.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jsilveira Jaime S
              Votes:
              4 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: