Skip to content

Preserve file extensions for generic attachments #6232#6250

Open
RomelaGG wants to merge 1 commit intosignalapp:mainfrom
RomelaGG:fix/preserve-file-extensions
Open

Preserve file extensions for generic attachments #6232#6250
RomelaGG wants to merge 1 commit intosignalapp:mainfrom
RomelaGG:fix/preserve-file-extensions

Conversation

@RomelaGG
Copy link
Copy Markdown

@RomelaGG RomelaGG commented May 5, 2026

First time contributor checklist

Contributor checklist

  • My commits are rebased on the latest main branch
  • My commits are in nice logical chunks
  • My contribution is fully baked and is ready to be merged as is
  • I have tested my contribution on these devices:
    • iPhone 12, iOS 26.3

Description

Fixes #6232

This fixes generic attachment exports losing their original filename extension when saved or shared.

Previously, AttachmentStream.makeDecryptedCopy(filename:) preferred the MIME-derived extension before the sender-provided filename extension. For generic file attachments this can be lossy, for example:

  • .srt attachments may have text/plain MIME type and save as .txt
  • .ipa attachments may have application/octet-stream MIME type and save as .bin

For attachments whose validated content type is .file, this change preserves the sender's filename extension when available. Media attachments still prefer MIME-derived extensions, preserving the existing behavior for images, videos, audio, and animated images.

I also replaced URL(string:) extension extraction with NSString.pathExtension, which is safer for normal filenames that contain spaces or non-URL-safe characters.

Testing:

  • Confirmed git diff --check passes.
  • Manually tested saving .srt and .ipa attachments to Files; both preserve their original file extensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Downloaded documents/files are incorrectly getting a .txt & .bin extension (iOS, iPadOS)

1 participant