email attachment filenames are sometimes corrupted

Description

I have a strange issue with cfmail and email attachments... If the name of an email attachment contains enough diacritical characters then when the email is delivered the attachment filename will be corrupted.

For example 'ThêQuickBrownFoxJúmpsOverTheDog.docx' is fine but 'ThêQuickBrøwnFoxJúmpsOverTheDog.docx' results in a file name resembling '=UTF-8QTh=C3=AAQuickBr=C3=B8wnFoxJ=C3=BAmpsOverTheDog.docx='.

I'm guessing this is an issue with the length of the filename and handling of utf-8 characters because even a relatively short name like 'ThêQúickƁrøwñƑøx.docx' is corrupted into '=UTF-8QTh=C3=AAQ=C3=BAick=C6=81r=C3=B8w=C3=B1=C6=91=C3=B8x.docx='.

A simpler example: 'ThêQuickBrownêFoxêJumpsOverTheDog.docx' is corrupted but 'ThêQuickBrownêFoxJumpsOverTheDog.docx' is not.

The same files sent via Gmail to the same recipient are delivered with the filenames as you would expect.

I'm thinking this is a Lucee bug but thought I would check here in case someone has seen this before (I couldn't find it in the backlog).

Tested on 5.3.10.79-RC and 5.3.9.141 - and yes, I have the charset attribute set to 'utf-8'

Environment

Lucee 5.3.10.79-RC (Windows) and 5.3.9.141 (Linux)

Attachments

2
  • 17 Oct 2023, 10:56 pm
  • 17 Oct 2023, 10:56 pm

Activity

Show:

Zac Spitzer 15 March 2024 at 15:29

windows doesn’t allow newlines in filenames, added a conditional regex to strip them out

https://github.com/lucee/Lucee/commit/5f5f00362a8f445661ce57e3c5bdc531c0f15fd8

Zac Spitzer 14 March 2024 at 08:51

this test fails on windows

https://github.com/lucee/Lucee/blob/6.1/test/tags/Mail2.cfc#L232

[java] [script] Errored: test.tags.Mail2 [java] [script] send part with umlaut in file name ans subject [java] [script] Invalid file [D:\\work\\lucee6\\test\\tags\\Das ist ein sehr langer sehr langer sehr langer sehr [java] [script] langer Filename mit Σ ─ ⁿ ▄ ▀ und ╓s und andere Leerzeichen.txt] [java] [script] D:\\work\\lucee6\\test\\tags\\Mail2.cfc:236 [java] [script] D:\\work\\lucee6\\test\\_testRunner.cfc:283 [java] [script] D:\\work\\lucee6\\test\\run-tests.cfm:284 [java] [script] [java] [script] lucee.runtime.exp.ApplicationException: Invalid file [D:\\work\\lucee6\\test\\tags\\Das ist ein sehr langer sehr langer sehr langer sehr [java] [script] langer Filename mit Σ ─ ⁿ ▄ ▀ und ╓s und andere Leerzeichen.txt] [java] [script] at lucee.runtime.functions.file.FileWrite.call(FileWrite.java:65) [java] [script] at lucee.runtime.functions.file.FileWrite.call(FileWrite.java:36) [java] [script] at tags.mail2_cfc$cf.udfCall2(/test/tags/Mail2.cfc:236) [java] [script] ... omitted verbose (ant / pagecontext / testbox) default stacktraces ... [java] [script] Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect [java] [script] at java.base/java.io.WinNTFileSystem.createFileExclusively(Native Method) [java] [script] at java.base/java.io.File.createNewFile(File.java:1035) [java] [script] at lucee.commons.io.res.type.file.FileResource.getOutputStream(FileResource.java:265) [java] [script] at lucee.runtime.functions.file.FileStreamWrapperWrite._getOS(FileStreamWrapperWrite.java:138) [java] [script] at lucee.runtime.functions.file.FileStreamWrapperWrite.write(FileStreamWrapperWrite.java:69) [java] [script] at lucee.runtime.functions.file.FileWrite.call(FileWrite.java:62) [java] [script] ... 100 more

Pothys - MitrahSoft 6 February 2024 at 16:47

I've checked this issue with lucee version 6.0.1.63-SNAPSHOT. File names are not corrupted when I send email attachment. This issue seems to be resolved. So I closed this ticket.

Michael Offner 6 February 2024 at 09:27

added a test case based on the example in the ticket

https://github.com/lucee/Lucee/commit/ef502a117ea7f7e79ec9a85092aeb2a1268acc2c

Fixed

Details

Assignee

Reporter

Priority

Fix versions

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 27 October 2022 at 11:06
Updated 23 January 2025 at 16:28
Resolved 6 February 2024 at 16:47

Flag notifications