Attachment Dropping: Failure to Decode File Names Properly During Mail Fetching

Attachment Dropping: Failure to Decode File Names Properly During Mail Fetching

Issue:
      The attachment is dropped due to invalid extension. 

 After decoding, the file name appears as:

Orange Załącznik nr 1 - Podsumowanie - uzupełnienie. xlsx(Contains space in the extension)

However, the actual file name should be:

Orange Załącznik nr 1 - Podsumowanie - uzupełnienie.xlsx

The issue arises because there is an extra space character in the extension after decoding from the email. As a result, the extension of the attachment is considered as invalid and discards it.

ErrorTrace:
[10:10:37:643]|[01-24-2024]|[com.adventnet.iam.security.SecurityRequestWrapper]|[SEVERE]|[273]: File extension do not match with the allowed extenions |
[10:10:37:643]|[01-24-2024]|[com.adventnet.iam.security.IAMSecurityException]|[INFO]|[273]: IAMSecurityException ErrorCode: INVALID_FILE_EXTENSION|
[10:10:37:643]|[01-24-2024]|[com.manageengine.servicedesk.v3api.utils.AttachmentAPIUtil]|[SEVERE]|[273]: Exception while writing Attachment file| 
com.adventnet.iam.security.IAMSecurityException: INVALID_FILE_EXTENSION
at com.adventnet.iam.security.UploadFileRule.validateFile(UploadFileRule.java:373)
at com.adventnet.iam.security.SecurityUtil.validateFile(SecurityUtil.java:2612)
at com.adventnet.iam.security.SecurityUtil.validateFileViaApiAndReturnResult(SecurityUtil.java:2596)
at com.adventnet.iam.security.SecurityUtil.validateFileViaApi(SecurityUtil.java:2591)
at com.manageengine.servicedesk.v3api.utils.AttachmentAPIUtil.uploadStreamAsAttachment(AttachmentAPIUtil.java:1596)
at com.manageengine.servicedesk.mailutils.MailAPI.uploadAttachment(MailAPI.java:2847)
at com.manageengine.servicedesk.mailutils.ModuleHandler.handleMailObject(ModuleHandler.java:111)
at com.adventnet.servicedesk.mailutils.MailProcessor.processEMail(MailProcessor.java:71)
at com.manageengine.servicedesk.mail.core.fetcher.EwsMailFetcher.fetchAndProcessMails(EwsMailFetcher.java:159)
at com.manageengine.servicedesk.mail.core.fetcher.MailFetcher.startFetching(MailFetcher.java:306)
at com.adventnet.servicedesk.helpdesk.mail.task.MailFetchingTask.executeTask(MailFetchingTask.java:39)
at com.adventnet.taskengine.internal.SchedulerBean.executeTask(SchedulerBean.java:641)
at sun.reflect.GeneratedMethodAccessor86.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.adventnet.mfw.bean.BeanProxy.lambda$invoke$0(BeanProxy.java:51)
at com.zoho.mickey.api.DefaultCodeBlock.execute(CodeBlock.java:453)
at com.adventnet.mfw.bean.BeanProxy.invoke(BeanProxy.java:48)
at com.sun.proxy.$Proxy5.executeTask(Unknown Source)
at com.adventnet.taskengine.internal.ScheduleExecutor.executeNextTask(ScheduleExecutor.java:334)
at com.adventnet.taskengine.internal.ScheduleExecutor.run(ScheduleExecutor.java:225)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

[10:10:37:643]|[01-24-2024]|[com.manageengine.servicedesk.mailutils.MailAPI]|[INFO]|[273]: Attchment dropped due to : INVALID_FILE_EXTENSION


Fix:
Apply the provided fixed JAR file to address the issue. This solution, outlined in the knowledge base, ensures correct filename decoding, enabling successful addition of the attachment.


Note:
Before applying the .fjar file, kindly verify its compatibility in the "Jar Compatibility" section below.


Steps to apply the fix:
1. Download the attached .fjar file.
2. Click here for steps to apply the .fjar file.
3. Restart the application service.
4. If the issue occurs again, enable the email debug in the application, recreate the issue after enabling the email debug then immediately zip the logs (<server_home>\logs folder. For eg: C:\Program Files\ManageEngine\ServiceDesk\logs folder) and share it with us for analysis. If the size of the log file is huge, you can send it to us using our FTP link https://bonitas2.zohocorp.com/. Select the product as "ServiceDesk Plus" and provide the proper ticket number.


Jar Compatibility:

Build
Compatible Jar
14503 & 14504
14504_9636989_Attachment_name_decode.fjar
14506 & 14600
14506_9560318_Attachment_name_decode.fjar
14620
14620_attachment.fjar

                    New to ADSelfService Plus?

                      • Related Articles

                      • Fix: Mail fetching stops due to invalid characters in the attachment name

                        Issue: Mail fetching being stopped due to invalid characters "?" , ":" in the filename. In this case, the eml file's subject contains ":" character and so, while uploading the .eml as attachment, error is thrown (Only in windows server) Trace: ...
                      • Mail Fetching - Error while processing attachment and inline image.

                        Issue During the process of fetching emails, attachments are dropped as a result of the presence of directory traversal characters. Furthermore, an issue arises when processing inline images, this particular error related to inline images results in ...
                      • Mail Fetching Stopped Due to Inline Image Handling

                        Issue Cause : While fetching a mail, in certain mail servers, cid of inline image is not parsed correctly. Once inline stream is converted to image, cid in src attr will be replaced with image url. cid for uploaded inline image in mail content is not ...
                      • Troubleshooting Oauth configuration for mail server settings

                        Oauth in ServiceDesk Plus / AssetExplorer for Mail SDP supports Oauth configuration for Office365 and GSuite mailboxes since 11106 build. Office365 mailboxes can be configured with Oauth authentication using EWS (since 11106) and IMAP / SMTP (since ...
                      • Fix JAR for Parse Error Exception Raised during Mail Fetching

                        Issue : Some mail are fetched and created as ticket without description due to message corruption temporarily. The issue is can be identified with the below trace. Fix : The issue is not recreated when the mail is skipped to next schedule and fetched ...