Patch #24186

Restrict the length attachment filenames on disk

Added by Holger Just about 1 year ago. Updated 11 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:


Target version:3.4.0


When uploading a file with a very long name, the disk_filename might be too long to be stored on the server's filesystem.

Since Redmine always prepends the timestamp to the name of the uploaded file, the final disk_filename will be longer than 255 characters (the common limit for filenames on most file systems) if the original filename is between 240 and 255 characters long. If that is the case, the attachment save will fail with a Errno::ENAMETOOLONG exception when attempting to write the file to disk.

The attached patch by Planio fixes this behavior by restricting the length of the filename 50 characters (to have some breathing room on unusual file systems). In that case, we just use the ASCII fallback we already have in place.

0001-Shorten-long-attachment-disk-filenames.patch Magnifier (1.68 KB) Holger Just, 2016-10-27 17:18

Associated revisions

Revision 16083
Added by Jean-Philippe Lang 11 months ago

Restrict the length attachment filenames on disk (#24186).

Revision 16084
Added by Jean-Philippe Lang 11 months ago

Fixed the assertion (#24186).


#1 Updated by Toshi MARUYAMA 12 months ago

  • Category set to Attachments
  • Target version set to 3.4.0

#2 Updated by Jean-Philippe Lang 11 months ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

Committed, thanks.

Also available in: Atom PDF