Skip to content

🐛 Quote the file path in the Open File action on Linux - #1603

Merged
Schneegans merged 3 commits into
kando-menu:mainfrom
ChandraChaan:fix/open-file-path-quoting
Nov 6, 2026
Merged

Schneegans merged 3 commits into
kando-menu:mainfrom
ChandraChaan:fix/open-file-path-quoting

Conversation

@ChandraChaan

Copy link
Copy Markdown
Contributor

On Linux the Open File action builds the command xdg-open "${action.path}", and exec() runs it through a shell (spawn(command, [], { shell: true })). Double quotes do not stop the shell from expanding $, backticks or \, and a " in the path ends the quoted string early. For an Open File item pointing at:

  • /home/user/$HOME-notes.txt, the shell expands $HOME and the wrong path is opened.
  • /home/user/Budget "2026".pdf, the shell joins it to Budget 2026.pdf.
  • /home/user/$(touch marker).txt, the touch command is run.

This wraps the path in single quotes and escapes any single quote inside it (as '\''), so the path reaches xdg-open unchanged. macOS and Windows use shell.openPath and are not affected.

I added test/unit-tests/open-file.spec.ts. It puts a fake xdg-open first on the PATH, runs the action, and checks that the script receives the path exactly as given (plain, spaces, $HOME, double quote, single quote, backtick, backslash). It also checks that a $(touch ...) in the path does not create the marker file. The spec is skipped on non-Linux platforms. I also added a line to the Fixed section of the changelog.

I did not run anything locally. I checked it in CI on my fork:

@Schneegans Schneegans left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you very much! Looks like a reasonable improvement 😄

@Schneegans
Schneegans merged commit 2113fd0 into kando-menu:main Nov 6, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants