data:image/gif URI `Save Page As` and `Save Image As` do not use the same filename
Categories
(Firefox :: File Handling, enhancement, P3)
Tracking
()
People
(Reporter: cpeterson, Assigned: ava8katushka)
Details
(Whiteboard: [outreachy-2021-downloads])
Attachments
(2 files, 4 obsolete files)
Updated•14 years ago
|
Comment 2•14 years ago
|
||
Comment 3•14 years ago
|
||
Comment 4•14 years ago
|
||
Comment 5•14 years ago
|
||
Comment 6•14 years ago
|
||
Updated•14 years ago
|
Comment 7•14 years ago
|
||
Comment 8•14 years ago
|
||
Comment 9•14 years ago
|
||
Comment 10•14 years ago
|
||
Comment 11•14 years ago
|
||
| Reporter | ||
Comment 12•14 years ago
|
||
Comment 13•14 years ago
|
||
Updated•14 years ago
|
Comment 14•14 years ago
|
||
Comment 15•14 years ago
|
||
Comment 16•14 years ago
|
||
Comment 17•14 years ago
|
||
Comment 18•14 years ago
|
||
| Reporter | ||
Comment 19•14 years ago
|
||
Updated•13 years ago
|
Updated•13 years ago
|
Updated•5 years ago
|
| Assignee | ||
Comment 20•5 years ago
|
||
Hello, I'm Ava, an outreachy intern, and I would like to take this bug to work on.
| Assignee | ||
Comment 21•5 years ago
|
||
I have mozilla local build set up, but I'm not sure I can reproduce the issue.
- I use photo of the dog: https://pocket-syndicated-images.s3.amazonaws.com/60639cdae32bd.jpg for the testing purposes.
- When I save it through right-click + "Save image as..." file is saved as "60639cdae32bd.jpg".
- Also when I click File > Save page as... file is saved as "60639cdae32bd.jpg".
- I also have the same names through bough paths while attempting to save an audio: https://www.mediacollege.com/audio/_assets/white-noise.mp3. In both cases, the file name is "white-noise.mp3".
ER:
Save Page AsandSave Image Asshould use the same filename when you are viewing an image directly (even if it is a data:image/gif).
The names are identical, so is this bug still actionable? Please tell me, if I'm missing something.
| Reporter | ||
Comment 22•5 years ago
|
||
Hi, Ava, thanks for taking on this bug! I'll assign this bug report to you.
I see that my bug summary does not match my steps to reproduce in comment 0. I'll fix that. This bug is specifically about a "data:image" URI (where the image data is actually encoded in the URI itself as Base64 text), not a URL pointing to an image file like https://pocket-syndicated-images.s3.amazonaws.com/60639cdae32bd.jpg.
Here is the "data:image" URI that I originally tested with. Just copy this URI, paste it into the address bar, and press Enter to load:
data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7
I can still reproduce this bug in Firefox 89 Nightly:
- File menu > "Save Page As" defaults to filename
(GIF Image, 16 × 14 pixels).gif. - Right-click on the tiny (folder) icon > "Save Page As" defaults to filename
index.gif. (Right-clicking on the page's black background and selecting "Save Page As" defaults to filename(GIF Image, 16 × 14 pixels).gif.
Open question: while we agree that the saved file should probably have the same filename, regardless of how it was saved, what do we actually want that filename to be? (GIF Image, 16 × 14 pixels).gif, index.gif, or something else?
Precedents from other browsers for comparison:
- Chrome (and Microsoft's Chromium Edge) on Windows and macOS default to filename
download.gif. - Safari on macOS defaults to filename
Unknown.gif.
As a user, if I see a data:image URI in the address bar and save it to a file, I would probably expect a filename like data.gif or image.gif. However, copying the precedent set by Chrome (download.gif) is always a safe choice. The engineer who reviews your code will probably have their own opinion. :) (We can't use a filename like data:image.gif because colon characters are not allowed in filenames on Windows or macOS.)
This bug report has an attachment with ancient code patch that apparently fixed this bug (nine years ago). I suggest reading that patch to get an idea of where to begin fixing this bug now. But beware that the Firefox code has changed a lot in the last nine years, so that patch's code changes might not be the fix needed today.
| Assignee | ||
Comment 23•5 years ago
|
||
| Assignee | ||
Comment 24•5 years ago
|
||
Thank you so much Chris for giving the detailed explanations on how to reproduce the bug and also guidance for my first bug as I'm trying to contribute. That was super, super helpful!!
Previous patches
I've tested the previous patches to this bug,
- !(aDocument instanceof Ci.nsIImageDocument) [669178]
- !aDocument.mozSyntheticDocument [669998]
None of them seems to work now.
Idea & Implementation
My idea is to check if it's a data URI of image/audio/video and return some standart response in this case.
Current implementation: https://phabricator.services.mozilla.com/D111857
I tested several cases with data URIs.
Test sketch
Image (Works with patch)
Currently: image data file, if saved through "Save page as", saves it as title, e.g "(GIF Image ..).gif" and when saved through "Save image as" saves as "index.gif"
Should be: saved in the same way through "Save page as" and "Save audio as" as "index.gif"
Audio (Doesn't work)
Currently: audio data mp3 file, if saved through "Save page as" is saved as "index.mp3" and if saved as "Save audio as" saves as "mp3.mp3".
Should be saved in the same way through "Save page as" and "Save audio as" as "index.mp3"
Problem
I figured out that while audio is saved, it doesn't use the same functions the images do. So it doesn't use the result of "getDefaultFileName" function or any functions two levels up. There it goes, I didn't still understand.
I hope my patch for images at least makes sense, and I'll wait the reviewer's feedback on it.
Updated•5 years ago
|
Updated•5 years ago
|
| Reporter | ||
Updated•5 years ago
|
Comment 25•5 years ago
|
||
Comment 26•5 years ago
|
||
Backed out changeset 714e6e7b8eef (Bug 789550) for causing failures in browser_default_audio_filename.js CLOSED TREE
Log: https://treeherder.mozilla.org/logviewer?job_id=337218854&repo=autoland&lineNumber=3258
Backout: https://hg.mozilla.org/integration/autoland/rev/65ae09788b53e3e06a831ebea3fa74c51d398394
| Reporter | ||
Comment 27•5 years ago
|
||
Ava, looks like your patch was backed out because your browser_default_audio_filename.js test is failing:
TEST-UNEXPECTED-FAIL | toolkit/content/tests/browser/browser_default_audio_filename.js | undefined assertion name - Got "index", expected "index.mp3"
You will need to fix your patch or the test and submit the new fix to Phabricator for a second review.
Comment 28•5 years ago
|
||
Comment 29•5 years ago
|
||
| bugherder | ||
Updated•5 years ago
|
Updated•5 years ago
|
Comment 30•5 years ago
|
||
Reproduced the initial issue using old Nightly from 2021-04-07, verified that saving the image and audio file from both page context menu or Main Menu will have the same name proposed to save. Verified on 90.0b5 across platforms (Windows 10, macOS 11.3 and Ubuntu 18.04).
Description
•