Closed Bug 1810197 Opened 3 years ago Closed 2 years ago

.exe extension becomes .com when downloading file

Categories

(Firefox for Android :: Downloads, defect, P2)

All
Android
defect

Tracking

()

RESOLVED FIXED
115 Branch
Tracking Status
firefox110 --- wontfix
firefox111 --- wontfix
firefox112 --- wontfix
firefox113 --- wontfix
firefox114 --- wontfix
firefox115 --- verified

People

(Reporter: csadilek, Assigned: jackyzy823)

References

(Blocks 1 open bug)

Details

(Keywords: webcompat:platform-bug)

Attachments

(5 files)

From github: https://github.com/mozilla-mobile/fenix/issues/27621.

Steps to reproduce

1.visit website https://2.na.dl.wireshark.org/win64/Wireshark-win64-4.0.1.exe

Expected behaviour

Downloaded Wireshark-win64-4.0.1.exe

Actual behaviour

Downloaded Wireshark-win64-4.0.1.com

Device name

MIUI12.6

Android version

andeoid 11

Firefox release type

Firefox

Firefox version

107.1.0 armv8 From github

Device logs

No response

Additional information

No response

┆Issue is synchronized with this Jira Task

Change performed by the Move to Bugzilla add-on.

Blocks: 1778322

The severity field is not set for this bug.
:cpeterson, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(cpeterson)

This might be a problem with the filename (contains dots) rather than the extension. Downloading .exe files with no dots in the filename does not reproduce this issue.

I can reproduce in both Fenix and Focus.

The problem is related to the .exe filename extension, not the multiple dots in the filename Wireshark-win64-4.0.1.exe: I can also reproduce the bug with the file Wireshark-win64-latest.exe, which has only one dot. Downloading Wireshark-win64-latest.msi, which doesn't have .exe, works correctly.

https://2.na.dl.wireshark.org/win64/

Severity: -- → S3
Rank: 233
Flags: needinfo?(cpeterson)
Priority: -- → P2

(In reply to Chris Peterson [:cpeterson] from comment #3)

I can reproduce in both Fenix and Focus.

The problem is related to the .exe filename extension, not the multiple dots in the filename Wireshark-win64-4.0.1.exe: I can also reproduce the bug with the file Wireshark-win64-latest.exe, which has only one dot. Downloading Wireshark-win64-latest.msi, which doesn't have .exe, works correctly.

https://2.na.dl.wireshark.org/win64/

I have been investigating the issue and I have discovered that a simple solution will be to update the GENERIC_CONTENT_TYPES array DownloadUtils in by adding "application/x-msdos-program" but this will break this comment as it wont be aligned with the desktop values. So is it possible to update the fenix values first before updating the desktop values?

Flags: needinfo?(csadilek)

Thanks for investigating!

I would have expected getExtensionFromMimeType to return exe and match the current file extension, therefore leaving it untouched.

Does it return com for you?

Flags: needinfo?(csadilek)

(In reply to Christian Sadilek [:csadilek] from comment #5)

Thanks for investigating!

I would have expected getExtensionFromMimeType to return exe and match the current file extension, therefore leaving it untouched.

Does it return com for you?

Yes it does, because application/x-msdos-program is not in GENERIC_CONTENT_TYPES line 179 in DownloadUtils will evaluate to false and changeExtension will be called and this will return com

Flags: needinfo?(csadilek)

After looking at some issues in Bugzilla I discovered that this issue was similar https://bugzilla.mozilla.org/show_bug.cgi?id=1812785. The URL returns null as the content-type , see this comment and therefore firefox assigns .bin as the extension to a PDF file.

Yes it does, because application/x-msdos-program is not in GENERIC_CONTENT_TYPES line 179 in DownloadUtils

No, sorry, that wouldn't be (and fix) the root cause. In the method I shared above getExtensionFromMimeType we look up the extension for the mime type. What values are you getting there for mimeType and extension when debugging?

The URL returns null as the content-type , see this comment and therefore firefox assigns .bin as the extension to a PDF file.

If I test the links above, I get application/x-msdos-program as mimetype, and exe and extension returned from getExtensionFromMimeType. I don't think you're getting a null mime-type, because then the extension wouldn't change, see: https://github.com/mozilla-mobile/firefox-android/blob/5d90029285ebafc64ed20e146e2c3d63087e6efd/android-components/components/support/utils/src/main/java/mozilla/components/support/utils/DownloadUtils.kt#L342.

Feel free to put up a patch and we can discuss details there.

Flags: needinfo?(csadilek)

Should if (typeFromExt?.equals(mimeType, ignoreCase = true) != false) { be if (typeFromExt?.equals(mimeType, ignoreCase = true) != true) { ?

Because we need to do getExtensionFromMimeType only when typeFromExt != mimeType.

Also a test shoud be added.
assertEquals("file.exe", DownloadUtils.guessFileName(null, null, "http://example.com/file.exe", "application/x-msdos-program"))

Reference: https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/webkit/URLUtil.java#374 which you said largely identical to
if (typeFromExt != null && !typeFromExt.equalsIgnoreCase(mimeType)) {

Flags: needinfo?(csadilek)

Not the author of this block, but this looks intentional to me. The first check is for the mimetype lookup to verify that the lookup was successful, before the file extension is compared.

But as I mentioned above, feel free to open a patch if you would like to work on a patch.

Flags: needinfo?(csadilek)
Status: NEW → RESOLVED
Closed: 2 years ago
Flags: qe-verify+
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch

Since nightly and release are affected, beta will likely be affected too.
For more information, please visit auto_nag documentation.

Verified as fixed on Nightly 114.0a1 from 04/23 with Motorola Moto G9 plus (Android 11). "Wireshark-win64-4.0.1.exe" is downloaded with the extension ".exe".

Arturo, did we want to nominate this for Beta uplift for v113? Please do if yes.

Flags: needinfo?(amejiamarmol)

Beta/Release Uplift Approval Request

User impact if declined: After downloading a .exe file users need to rename it after download as it get renamed to .com
Is this code covered by automated tests? Yes
Has the fix been verified in Nightly? Yes
Risk to taking this patch: Low
List of other uplifts needed: None
Why is the change risky/not risky? (and alternatives if risky) This patch is low risk as it's only changing the way we rename the extension part of the file when we don't have the content type available.
String changes made/needed No
Is Android affected? Yes

Flags: needinfo?(amejiamarmol) → needinfo?(brclark)

I approve the uplift

Flags: needinfo?(brclark)
Status: RESOLVED → REOPENED
Flags: qe-verify+
Resolution: FIXED → ---
Target Milestone: 114 Branch → ---

@jackyzy823 I had to revert your patch as it was addressing this specific issue but introducing an unwanted code path, I added a longer explanation here, sorry about the misunderstanding. I'm drafting a possible fix locally that will also refactor the initial function which was bit tricky to parse.

@jackyzy823 here you can see the patch, I refactor the function to make it bit clear and kept your original tests :)

Status: REOPENED → RESOLVED
Closed: 2 years ago2 years ago
Flags: qe-verify+
Resolution: --- → FIXED
Target Milestone: --- → 115 Branch

Verified as fixed on Nightly 115.0a1 from 05/25 with Motorola Moto G9 plus (Android 11). "Wireshark-win64-3.6.14.exe" is downloaded with the extension ".exe".

Thanks Adina 🎉!

Duplicate of this bug: 1812794
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: