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

Escape SSH commands correctly #954

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from

Conversation

prudloff-insite
Copy link
Contributor

Overview

This pull request:

  • Fixes a bug
  • Adds a feature
  • Breaks backwards compatibility
  • Has tests that cover changes
  • Adds or fixes documentation

Summary

This changes the way SSH commands are escaped in order to work with commands containing '.

Description

Consider the following code:

    $gitTask = $this->taskGitStack()
      ->commit('foo bar');

    $this->taskSshExec()
      ->exec($gitTask)
      ->run();

Without this patch, it will produce (which will fail):

ssh server 'cd "/path/" && git commit -m 'foo bar''

And with the patch:

ssh server 'cd "/path/" && git commit -m '\''foo bar'\'''

(Now the Git message is escaped correctly.)

Sorry, we are still stuck on Robo 1.4.12 but I would understand if you didn't want to merge a fix on this old branch.

@greg-1-anderson
Copy link
Member

This looks good, but it will need to go in on the default branch first. The code should be about the same there.

Only escape if needed
@prudloff-insite prudloff-insite changed the base branch from 1.x to 3.x December 19, 2022 16:35
@prudloff-insite prudloff-insite changed the base branch from 3.x to 1.x December 19, 2022 16:36
@prudloff-insite
Copy link
Contributor Author

There is a PR for the 3.x branch here: #989

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