Open Bug 1983068 Opened 2 months ago Updated 9 days ago

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)

Firefox 141
defect

Tracking

()

ASSIGNED

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.

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.

Component: Untriaged → Widget: Gtk
Product: Firefox → Core

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'"
Flags: needinfo?(gouthierenicolas12)
Attached file Terminal output
` `

(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'"

https://bugzilla.mozilla.org/attachment.cgi?id=9507429

Flags: needinfo?(gouthierenicolas12)

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.

Flags: needinfo?(emilio)
Flags: needinfo?(jhorak)

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).

Flags: needinfo?(emilio) → needinfo?(thinker.li)
Blocks: flatpak, snap
Summary: When saving an image in Firefox on KDE Plasma via xdg-desktop-portal-kde, filenames containing a colon (:) are saved with a random .xdp-… temporary name instead of the chosen name. → 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.

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

Flags: needinfo?(thinker.li)

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.

Let's consider users are sane when choosing file name.

Assignee: nobody → jhorak
Attachment #9516406 - Attachment description: WIP: Bug 1983068 Don't sanitize filename returned by file picker; :sinker → Bug 1983068 Don't sanitize filename returned by file picker; r=thinker
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: