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

Properly quote path argument to Start-Process #308

Merged
merged 6 commits into from
Oct 27, 2019

Conversation

vexx32
Copy link
Owner

@vexx32 vexx32 commented Oct 27, 2019

PR Summary

Start-Process doesn't pass through non-explicit quotes.
This unfortunately means paths with spaces get read as two arguments.

Fix is to properly insert explicit quotes to the argument first.

Context

There's no reason not to support spaces in paths. This is 2019, c'mon. 😋

Resolves #306

Changes

  • Tidy up path resolution logic.
  • Refactor Start-Process splat table to insert explicit quotes in the path argument.

Checklist

  • Pull Request has a meaningful title.
  • Summarised changes.
  • Pull Request is ready to merge & is not WIP.
  • Added tests / only testable interactively.
    • Make sure you add a new test if old tests do not effectively test the code changed.
  • Added documentation / opened issue to track adding documentation at a later date.

Start-Process doesn't pass through non-explicit quotes.
This unfortunately means paths with spaces get read as two arguments.

Fix is to properly insert explicit quotes to the argument first.
@vexx32 vexx32 added PR-Needs-Review 🔍 Let's take a closer look! Category-Module Pertaining to the module's functionality itself. labels Oct 27, 2019
@camusicjunkie
Copy link

Your modified code looks like what was previously implemented before #289. Will this create the issue again described in #284?

@vexx32
Copy link
Owner Author

vexx32 commented Oct 27, 2019

@camusicjunkie the issue in #284 arose because we didn't think to use either Resolve-Path or Get-Item before passing the path to Start-Process. Provided we do that, this should continue to work.

The reason I reverted to a more similar pattern to the original is mainly because I suspect the additional complexity of the methods utilized in #289 made it harder for us to catch the regression here in terms of proper handling of paths with spaces during review.

If you'd like to verify for yourself, you can pull the built module from the CI artifacts and test to be sure it behaves as you'd expect. 😊

I'll look into possible avenues of expanding our testing to ensure we don't get tripped up like this again! 💖

Add a test case to ensure that we pass a resolved and quote path.
If we do not resolve and quote the path, it will break things.
Resolve-Path doesn't handle embedded quotes.
Strip quotes before checking if the path is resolved correctly.
@vexx32 vexx32 force-pushed the Bug/MeditateFixPathsWithSpaces branch from 9d2b697 to da017b0 Compare October 27, 2019 22:38
@vexx32 vexx32 merged commit 75c26ef into master Oct 27, 2019
@vexx32 vexx32 deleted the Bug/MeditateFixPathsWithSpaces branch October 27, 2019 23:01
@vexx32 vexx32 removed the PR-Needs-Review 🔍 Let's take a closer look! label Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category-Module Pertaining to the module's functionality itself.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show-Karma -Meditate doesn't open editor correctly when a space exists in user path
2 participants