-
Notifications
You must be signed in to change notification settings - Fork 118
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
Comments
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! |
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. |
@mwrock =^.^= |
Merged the PR, thanks guys. |
WinRM/lib/winrm/winrm_service.rb
Line 122 in ccafbf0
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.
The text was updated successfully, but these errors were encountered: