fix: convert filesystem paths to file:// URLs for Linux file manager (#12272) #12300
+16
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12272.
Root cause:
show_in_finder()on Linux passes bare filesystem paths (e.g.,/home/me/Projects/Launcher/Launcher) directly toopen_that(). Theopen_that()function parses its input withUrl::parse(), which requires a valid URL with a scheme. Bare filesystem paths lack a scheme and fail with the error:Invalid path format: '...' → relative URL without a base.Note: This only affects Linux. On macOS and Windows,
show_in_finder()usesCommand::new("open")andCommand::new("explorer")respectively, bypassingopen_that()entirely.Fix: Two minimal changes:
file://URLs usingUrl::from_file_path()in the Linux block ofshow_in_finder(), soopen_that()receives a valid URL."file"to the allowed URL schemes inopen_that()sofile://URLs pass the scheme validation.Changes
crates/but-api/src/legacy/open.rs:open_that(): Added"file"to the allowed URL schemes whitelist.show_in_finder()(Linux block): Refactored to convert the target directory path to afile://URL viaUrl::from_file_path()before passing toopen_that(). This ensuresxdg-openreceives a properly formatted URL.Root Cause Analysis
The
open_that()function was designed for opening URLs (http, https, vscode://, etc.) and performs URL parsing + scheme validation. Whenshow_in_finder()on Linux was implemented, it reusedopen_that()for filesystem paths without converting them to URLs first. macOS and Windows code paths use directCommand::new()calls and don't go throughopen_that(), which is why this bug is Linux-specific.Risk Assessment
filescheme is safe — it only opens the system file manager viaxdg-open.open_that()for file manager operations.open_that()still handles the command execution.