tracker issue : CF-4204630

select a category, or use search below
(searches all categories and all time range)
Title:

Illegal characters in attachment file name

| View in Tracker

Status/Resolution/Reason: Open//

Reporter/Name(from Bugbase): Alex F. / ()

Created: 06/26/2019

Components: CFExchange

Versions: 2016

Failure Type: Non Functioning

Found In Build/Fixed In Build: 2016.0.04.302561 /

Priority/Frequency: Normal / All users will encounter

Locale/System: English / Win 2012 Server x64

Vote Count: 0

Problem Description:
When using the "getAttachments" action of the cfexchange tag, files with names that contain illegal characters (such as colon or angle brackets) will throw an error and will not be saved to disk. Here are some examples of invalid file names of attachments I have received: "Company: Invoice.pdf", "<INVOICE.PDF>.PDF",  "C:\Users\JohnD\App\Data\Local\Temp\Invoice.pdf". When I download the attachment using Outlook, it correctly removes the illegal characters like this: "Company Invoice.pdf", "INVOICE.PDF", "CUsersJohnDAppDataLocalTempInvoice.pdf". But ColdFusion attempts to save them as "Company: Invoice.pdf", "<INVOICE.PDF>.PDF", "C:UsersAbbyDAppDataLocalTempInvoice.pdf". In the last example, the slashes are correctly removed, but the colon remains. Since these file names include invalid characters for the NTFS file system (see the reserved characters listed here: https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file), the files fail to save to disk and an exception is thrown.

Steps to Reproduce:
Use cfexchange to download a file whose name contains illegal characters. I do not know how to generate such a file, but it must be possible in some non-NTFS file systems or non-Windows operating systems. Example code is attached to this bug report.

Actual Result:
An exception is thrown. The type of exception seems to depend on the characters in the file name.
For a file with a colon (:) in the name:
    Type = "java.nio.file.InvalidPathException"
    Message = "Illegal char <:> at index N: \\filestore\Company: Invoice.pdf"
For a file with a less than (<) or greater than (>) in the file name: 
    Type = "Application"
    Message = "Error reading or writing attachment."
    Detail = "Attachment path = \\filestore\<INVOICE.PDF>.PDF."

Expected Result:
The file is written to disk without the invalid characters.

Any Workarounds:
No software solution. The mailbox has to be monitored manually for invalid file names.

Attachments:

Comments: