Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows: Always double-quote path when launching explorer.exe to browse #78963

Merged
merged 1 commit into from
Aug 28, 2023

Conversation

bgie
Copy link
Contributor

@bgie bgie commented Jul 2, 2023

Fixes #78949

Code now always double quotes the filename to use as command line argument when calling 'explorer.exe'. In particular, commas in a filename would be interpreted by 'explorer.exe' as separators for commands.

Fixed the logic logic where existing leading or trailing double quotes in the filename were duplicated, instead of adding them when they were missing.

Similarly a trim_suffix for "file://" is assumed to be a mistake, this could potentially be a _pre_fix that we want to strip, but never a suffix.

Judging from the commit that first introduced the OS_Windows::shell_show_in_file_manager function I would guess that stripping "file://" was some intermediate decision that might not be needed in the end, and never even worked. The old code would prefix "file://" at several locations, but this was all moved to the base implementation of shell_show_in_file_manager, and the new windows implementation never prefixes, so there is no need for trimming.

Maybe trimming the prefix could be dropped altogether, but I'm playing safe. I do not know if there are usages of this method that I am unaware of. If this method is exposed to GDScript or plugins use it, that code could still be prefixing "file://", hence we need to strip it for the windows version.

@bgie bgie requested a review from a team as a code owner July 2, 2023 21:04
@bgie
Copy link
Contributor Author

bgie commented Jul 2, 2023

Tested this myself on Windows 11 Pro

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like 3 straightforward typo fixes.

@akien-mga akien-mga added the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Aug 17, 2023
Code now always double quotes the filename to use as command line
argument when calling explorer.exe. In particular, commas in a filename
would be interpreted by explorer.exe as separators for commands.

Similarly a trim_suffix for "file://" is assumed to be a mistake, this
could potentially be a PREfix that we want to strip, but never a suffix.
Since it didn't seem needed in the end, we removed it.
@akien-mga akien-mga changed the title Always double-quote file or folder name when launching explorer.exe to browse Windows: Always double-quote path when launching explorer.exe to browse Aug 28, 2023
@akien-mga
Copy link
Member

I pushed my suggested changes, but didn't test (I'm on Linux). CC @bruvzg

@akien-mga akien-mga merged commit 6584cd8 into godotengine:master Aug 28, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

@YuriSizov YuriSizov removed the cherrypick:4.1 Considered for cherry-picking into a future 4.1.x release label Oct 24, 2023
@YuriSizov
Copy link
Contributor

Cherry-picked for 4.1.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Project Manager, comma in project name, breaks open project folder button
4 participants