mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
Attachment filenames were sanitized for path traversal but never length-limited, so a very long name (made worse by multibyte UTF-8 chars like German umlauts, 2 bytes each) produced an on-disk component "<id>-<version>-<name>" exceeding the filesystem's 255-byte per-path-component limit. Migrating such files from GridFS to filesystem storage then failed with ENAMETOOLONG (errno -36). sanitizeFilename now truncates the name to 200 UTF-8 bytes, measured in bytes (not characters) and never splitting a multibyte codepoint, while preserving the file extension. 200 bytes leaves headroom for the "<id>-<version>-" prefix so the full component stays under 255 bytes. Applied centrally in sanitizeFilename so every path-construction and lookup site stays consistent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>