When saving an image in Firefox on KDE Plasma via xdg-desktop-portal-kde on snap or flatpak, filenames containing a colon (:) are saved with a random .xdp-… temporary name instead of the chosen name.
Categories
(Core :: Widget: Gtk, defect)
Tracking
()
People
(Reporter: gouthierenicolas12, Assigned: jhorak, NeedInfo)
References
(Blocks 2 open bugs)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0
Steps to reproduce:
Use Firefox on KDE Plasma (Wayland session)
Right-click an image in a webpage → Save Image As….
In the save dialog, keep the suggested filename or type a filename that contains a colon (:), e.g. Test:Image.png.
Choose a location and click Save.
Actual results:
Instead of the file being saved with the given name, a file with a name like:
.xdp-Test_Image.png-QzSFNL
Expected results:
The file should be saved with the exact name given in the save dialog, including the colon character, or at least sanitized correctly just as in other Linux file saving dialogs.
Comment 1•2 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 months ago
|
||
Not sure where the prefix and suffix come from. But, colons are illegal when save a file in Firefox.
Could you try the following command? It may catch what is sent from the xdg-desktop-portal.
dbus-monitor "sender='org.freedesktop.portal.Desktop'"
(In reply to Thinker Li [:sinker] from comment #2)
Not sure where the prefix and suffix come from. But, colons are illegal when save a file in Firefox.
Could you try the following command? It may catch what is sent from the xdg-desktop-portal.
dbus-monitor "sender='org.freedesktop.portal.Desktop'"
Comment 5•24 days ago
|
||
According to the log you provided, xdg-desktop-portal should return file:///run/user/1000/doc/45672698/The%20Last%20of%20Us:%20Part%201.png
to Firefox. This is the filename (path) in the container and Firefox can write to only this path. It can not change the name of the file. It is xdg-desktop-portal's responsibility to map this path in container to a path in the host.
However, Firefox should sanitize file name and replace ':' with '_'. And, Firefox did write to the sanitized path successfully. Does this trigger a weird behavior on xdg-desktop-portal-kde? Maybe we should ask KDE community about this.
Updated•24 days ago
|
Updated•24 days ago
|
Comment 6•23 days ago
|
||
Thinker do you know why we sanitize the :
away (and where that code is)?
I'm assuming this is only an issue for flatpak or snap. Testing with the portal picker on Nightly and on KDE, I get the expected behavior given Thinker's comment (e.g., I save as example:image.png
and get example_image.png
).
Updated•23 days ago
|
Comment 7•23 days ago
•
|
||
Here you go [1].
If you check the comment of OS_FILE_ILLEGAL_CHARACTERS
& CONTROL_CHARACTERS
[2], they are in most restrictive way in order to work in most platforms.
[1] https://searchfox.org/firefox-main/source/uriloader/exthandler/nsExternalHelperAppService.cpp#3546
[2] https://searchfox.org/firefox-main/source/xpcom/base/nsCRTGlue.h#170
Comment 8•23 days ago
•
|
||
I think sanitizing the file name returned from the file picker is debatable since it is what user chose, not a random name over Internet.
So, it could be better to skip sanitizer for the file name picked by the user. We probably should sanitize the suggested name passing to the file picker, but not the one returned from the picker.
Assignee | ||
Comment 9•9 days ago
|
||
Let's consider users are sane when choosing file name.
Updated•9 days ago
|
Description
•