Skip to content

fix: percent-encode paths passed to org.freedesktop.FileManager1 - #54350

Merged
MarshallOfSound merged 1 commit into
mainfrom
fix/linux-show-item-in-folder-uri
Sep 25, 2026
Merged

MarshallOfSound merged 1 commit into
mainfrom
fix/linux-show-item-in-folder-uri

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Description of Change

On Linux desktops without the OpenURI portal, shell.showItemInFolder() calls org.freedesktop.FileManager1.ShowItems with "file://" + path, so a path containing #, ? or % selects the wrong item or nothing. Percent-encode the raw path bytes with base::EscapePath(). (net::FilePathToFileURL(), which upstream's platform_util_linux.cc uses, first decodes the path through the C library locale and returns an empty path for non-ASCII names under a C/POSIX locale, so it is not used here.)

Also keep every in-flight portal OpenDirectory request instead of only the most recent one, and don't fall back to opening the parent folder when the portal request was cancelled by the user (both matching upstream).

Checklist

Release Notes

Notes: Fixed shell.showItemInFolder() on Linux for paths containing #, ? or % when the file manager is reached over D-Bus.

@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@MarshallOfSound MarshallOfSound self-assigned this Sep 25, 2026
@MarshallOfSound
MarshallOfSound force-pushed the fix/linux-show-item-in-folder-uri branch from 1c97ec0 to a45e144 Compare September 25, 2026 10:12
shell.showItemInFolder() built the FileManager1 ShowItems URI as
"file://" + path, so a path containing '#', '?' or '%' selected the wrong
item or nothing. Percent-encode the raw path bytes with base::EscapePath()
(net::FilePathToFileURL() would decode the path through the C library
locale first and drop non-ASCII paths under a C/POSIX locale). Also keep
every in-flight portal OpenDirectory request instead of only the latest
one, and don't fall back to opening the parent folder when the portal
request was cancelled by the user.
@MarshallOfSound
MarshallOfSound force-pushed the fix/linux-show-item-in-folder-uri branch from a45e144 to 1de2c11 Compare September 25, 2026 10:30
@MarshallOfSound
MarshallOfSound merged commit 7b0b906 into main Sep 25, 2026
73 checks passed
@release-clerk

release-clerk Bot commented Sep 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed shell.showItemInFolder() on Linux for paths containing #, ? or % when the file manager is reached over D-Bus.

@MarshallOfSound
MarshallOfSound deleted the fix/linux-show-item-in-folder-uri branch September 25, 2026 16:07
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/44-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54386

@trop trop Bot added in-flight/45-x-y and removed target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "44-x-y", please check out #54406

@trop trop Bot added in-flight/44-x-y merged/45-x-y PR was merged to the "45-x-y" branch. and removed needs-manual-bp/44-x-y in-flight/45-x-y labels Sep 25, 2026
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…x-y) (#54406)

fix: percent-encode paths passed to org.freedesktop.FileManager1 (#54350)

shell.showItemInFolder() built the FileManager1 ShowItems URI as
"file://" + path, so a path containing '#', '?' or '%' selected the wrong
item or nothing. Percent-encode the raw path bytes with base::EscapePath()
(net::FilePathToFileURL() would decode the path through the C library
locale first and drop non-ASCII paths under a C/POSIX locale). Also keep
every in-flight portal OpenDirectory request instead of only the latest
one, and don't fall back to opening the parent folder when the portal
request was cancelled by the user.

(cherry picked from commit 7b0b906)
@trop trop Bot removed the in-flight/44-x-y label Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants