Closed Bug 1768898 Opened 3 years ago Closed 3 years ago

Bad file extension when using an HTMLAnchorElement

Categories

(Firefox :: File Handling, defect, P1)

Firefox 102
defect
Points:
2

Tracking

()

VERIFIED FIXED
102 Branch
Tracking Status
firefox-esr91 --- unaffected
firefox100 --- unaffected
firefox101 --- unaffected
firefox102 --- verified

People

(Reporter: github.christian, Assigned: enndeakin)

References

(Regression)

Details

(Keywords: regression, Whiteboard: [fidefe-quality-foundation])

Attachments

(2 files)

Attached file index.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0

Steps to reproduce:

I try to save a JSON string in a file, using window.URL.createObjectURL , then passing the ObjectURL to an HTMLAnchorElement with the attribute download set to the desired file name and extension ( see the attached index.html file )

Actual results:

The file is saved but a .json extension is added to the file name and extension so the file have two extensions.

Expected results:

The .json extension must not be added to the file name.
Work fine in Firefox 100 and others browsers.
See also bug 1673061 already created by me for a similar problem in version 84 and solved since.
The actual problem occurs only when the type of the file is 'application/json' (see code in the attached index.html file).

The Bugbug bot thinks this bug should belong to the 'Core::DOM: File' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: File
Product: Firefox → Core

"Regressed" by bug 1746052. Looks intentional, but admittedly application/json is also kinda special in this case as it can be used with random file extensions AFAIK. NI'ing Neil for details.

Component: DOM: File → File Handling
Flags: needinfo?(gijskruitbosch+bugs)
Product: Core → Firefox
Regressed by: 1746052
Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(enndeakin)

(In reply to github.christian from comment #0)

See also bug 1673061 already created by me for a similar problem in version 84 and solved since.

Should bug 1673061 be closed?

Flags: needinfo?(github.christian)

(In reply to Kagami :saschanaz from comment #2)

application/json is also kinda special in this case as it can be used with random file extensions AFAIK. NI'ing Neil for details.

Yeah, we stopped overwriting with .json in bug 1684183. I don't know why that patchset would have caused us to start doing so again, but I somewhat doubt it's intentional.

Set release status flags based on info from the regressing bug 1746052

(in reply to :Gijs (he/him) Should bug 1673061 be closed?
For me yes, bug 1673061 can be closed. The bug appears only in the nightly builds of Firefox 84 and not in the final version of Firefox 84.

Flags: needinfo?(github.christian)
Has Regression Range: --- → yes

The bug has a release status flag that shows some version of Firefox is affected, thus it will be considered confirmed.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Gijs, could we get a priority/severity set? It's not clear to me if the user impact is potentially significant for the 102 release, thanks!

Flags: needinfo?(gijskruitbosch+bugs)
Assignee: nobody → enndeakin
Status: NEW → ASSIGNED
Flags: needinfo?(enndeakin)

I can't reproduce the problem so I'm not sure how to prioritize this. Is this Windows-specific? Neil, did you already try to reproduce?

Flags: needinfo?(gijskruitbosch+bugs) → needinfo?(enndeakin)

Yes, I can reproduce on Mac at least. I think we can change this to just never change the extension for zip/json/xml which are the three types that were handled in 1684183.

Flags: needinfo?(enndeakin)
Severity: -- → S2
Priority: -- → P1
Whiteboard: [fidefe-quality-foundation]

Neil, can we get this landed before the merge? Thanks

Flags: needinfo?(enndeakin)
Pushed by neil@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/cf4f521a210e special case zip, json, and xml to allow these files to be saved with any extension, r=Gijs
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 102 Branch
Flags: needinfo?(enndeakin)
Flags: qe-verify+
Points: --- → 2

Reproduced the issue with Firefox 102.0a1 (20220511214930) on Windows 10x64. The downloaded file from the attached test case has .json extension when downloaded.
The issue is verified fixed with Firefox 102.0b3 (20220602190016) on Windows 10x64, macOS 11, and Ubuntu 21.10. The .json extension is no longer added to the downloaded file from the attached test case.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: