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

Use of sub! in run_command results in spurious capture/replacement of \& sequences. #131

Closed
ksubrama opened this issue Mar 20, 2015 · 4 comments

Comments

@ksubrama
Copy link

def run_command(shell_id, command, arguments = [], cmd_opts = {})

run_command performs xml.sub!(escaped_cmd, escaped_cmd.gsub(/'/, "'")) to work around a framework issue from #73 but sub looks for backreferences in the replacement string. Doing Regexp.escape on the replacement string should correct this but this seems like going around one's head to touch one's nose but I can't think of a simpler way to do it.

A real-life example of this occurring is when you pass "" anywhere in your command because it gets escaped to "" which causes & to be captured.

@mwrock
Copy link
Member

mwrock commented Mar 24, 2015

Hey @ksubrama do you think you could add a test for this in https://github.com/WinRb/WinRM/blob/master/spec/cmd_spec.rb ? In addition to defending from regressions it would also better illustrate your example above. Thanks!

@ksubrama
Copy link
Author

Done! Let me know if this is enough. I actually found an issue with my initial implementation in the process. The current version passes all tests.

@ksubrama
Copy link
Author

@mwrock =^.^=

@sneal
Copy link
Member

sneal commented Mar 31, 2015

Merged the PR, thanks guys.

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

No branches or pull requests

3 participants