JIRA fails to add attachments with long filenames from RFC 2231-compliant mail clients

XMLWordPrintable

      Mail clients like Thunderbird will break long attachment names up into multiple short lines, as per RFC 2231:

      Content-Type: application/pdf;
      name*0="alreallyreallyreallylongfilenamewithlogsoftextthatshouldlinewrap";
      name*1=".pdf"
      Content-Transfer-Encoding: base64
      Content-Disposition: inline;
      filename*0="alreallyreallyreallylongfilenamewithlogsoftextthatshouldline";
      filename*1="wrap.pdf"

      Unfortunately JavaMail (as of 1.4) does not support this aspect of RFC 2231. JIRA will fail to add the attachment, and in the logs prints something like:

      2007-04-11 17:48:28,604 JiraQuartzScheduler_Worker-3 DEBUG [service.util.handler.AbstractMessageHandler] part=javax.mail.internet.MimeBodyPart@13cd5b5
      2007-04-11 17:48:28,605 JiraQuartzScheduler_Worker-3 DEBUG [service.util.handler.AbstractMessageHandler] Filename=null, content type=application/pdf;^M
      name*0="alreallyreallyreallylongfilenamewithlogsoftextthatshouldlinewrap";^M
      name*1=".pdf", content=com.sun.mail.util.BASE64DecoderStream@f27b6e
      2007-04-11 17:48:28,605 JiraQuartzScheduler_Worker-3 WARN [jira.issue.managers.DefaultAttachmentManager] Cannot create attachment without a filename - inline content? See http://jira.atlassian.com/browse/JRA-10825 (file=tempattach34617dat).
      2007-04-11 17:48:28,605 JiraQuartzScheduler_Worker-3 DEBUG [service.util.handler.AbstractMessageHandler] Encountered an error creating the attachment null for issue TP-39
      2007-04-11 17:48:28,605 JiraQuartzScheduler_Worker-3 DEBUG [service.services.mail.MailFetcherService] Deleting Message: <461C92BC.1030609@atlassian.com>

      JavaMail may also to even parse the email, and can die with:

      2007-04-11 17:50:28,128 JiraQuartzScheduler_Worker-1 ERROR [service.util.handler.CreateIssueHandler] Could not create issue!
      javax.mail.internet.ParseException: Missing charset in encoded value: %61%6C%6C%79%6C%6F%6E%67%66%69%6C%65%6E%61%6D%65%77%69%74%68
          at javax.mail.internet.ParameterList.decodeValue(ParameterList.java:385)
          at javax.mail.internet.ParameterList.<init>(ParameterList.java:175)
          at javax.mail.internet.ContentDisposition.<init>(ContentDisposition.java:87)
          at javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:1039)
          at javax.mail.internet.MimeBodyPart.getDisposition(MimeBodyPart.java:299)
          at com.atlassian.jira.service.util.handler.AbstractMessageHandler.saveAttachment(AbstractMessageHandler.java:311)
          at com.atlassian.jira.service.util.handler.AbstractMessageHandler.handleMultipart(AbstractMessageHandler.java:295)
          at com.atlassian.jira.service.util.handler.AbstractMessageHandler.createAttachmentsForMessage(AbstractMessageHandler.java:243)
          at com.atlassian.jira.service.util.handler.CreateIssueHandler.handleMessage(CreateIssueHandler.java:202)
          at com.atlassian.jira.service.util.handler.CreateOrCommentHandler.handleMessage(CreateOrCommentHandler.java:115)
          at com.atlassian.jira.service.services.mail.MailFetcherService.run(MailFetcherService.java:190)
          at com.atlassian.jira.service.JiraServiceContainerImpl.run(JiraServiceContainerImpl.java:67)
          at com.atlassian.jira.service.ServiceRunner.execute(ServiceRunner.java:48)
          at org.quartz.core.JobRunShell.run(JobRunShell.java:191)
          at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:516)
      

      In this case, the mail is left in the queue, and you will see these stacktraces repeated in the logs every time the mail service triggers (usu. once a minute).

            Assignee:
            Unassigned
            Reporter:
            Jeff Turner
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 4h
                4h