Signal-Android icon indicating copy to clipboard operation
Signal-Android copied to clipboard

Saved attachments with contentType "image/jpg" named with ".attach" extension

Open unrulygnu opened this issue 11 years ago • 5 comments

In SaveAttachmentTask.java, the call to mimeTypeMap.getExtensionFromMimeType(contentType) with the type image/jpg returns null on devices with the AOSP version of MimeUtils.java. This is because the Android platform doesn't recognize image/jpg as a valid MIME type.

With the image/jpeg type, however, an extension is returned as expected.

MimeUtils.java (AOSP)

    add("image/ief", "ief");
    // add ".jpg" first so it will be the default for guessExtensionFromMimeType
    add("image/jpeg", "jpg");
    add("image/jpeg", "jpeg");
    add("image/jpeg", "jpe");
    add("image/pcx", "pcx");

I've dealt with issues in the past where device manufacturers have edited this map (love you, Samsung ㅗ*.*ㅗ), which may result in sending devices using content types which receiving devices cannot look up via getExtensionFromMimeType. Where to put a sanitizer might be a bit tricky. I'll dig deeper tomorrow.

unrulygnu avatar Nov 19 '15 12:11 unrulygnu

I think this is related to #4536 but this has some evidence to the reasons.

JavaJens avatar Nov 19 '15 12:11 JavaJens

A friend of mine still has this problem with 3.7.1. Can someone confirm? Or are old attachments not fixed by this commit?

mawed avatar Dec 09 '15 15:12 mawed

@mawed: I tested this on message attachments received both before and after the patch. A few questions:

  1. What was the file extension of the attached file on the sender's device?
  2. Was the file sent via Signal or MMS? If Signal, what version?
  3. What devices and OS versions do the sender and receiver have?

unrulygnu avatar Dec 11 '15 04:12 unrulygnu

As a test he sent me a mp4 today. Saving it, I got an .attach file. I use Android signal 3.7.2. He uses also Android signal.

The video was sent using signal message.

He also stated, the problem was gone some versions ago. Am 11. Dezember 2015 05:16:51 MEZ, schrieb Geonu Kang [email protected]:

@mawed: I tested this on message attachments received both before and after the patch. A few questions:

  1. What was the file extension of the attached file on the sender's device?
  2. Was the file sent via Signal or MMS? If Signal, what version?
  3. What devices and OS versions do the sender and receiver have?

Reply to this email directly or view it on GitHub: https://github.com/WhisperSystems/Signal-Android/issues/4602#issuecomment-163835166

mawed avatar Dec 11 '15 09:12 mawed

@mawed: This issue and related PR addressed only issues caused by MIME type image/jpg.

See Issue #4536 and PR #4689 regarding videos. I have to update the PR, should be fixed soon.

unrulygnu avatar Dec 16 '15 07:12 unrulygnu