Skip to content

Preserve MSCmd whitespace arguments#58

Open
salva wants to merge 1 commit into
masterfrom
fix/mscmd-argument-quoting
Open

Preserve MSCmd whitespace arguments#58
salva wants to merge 1 commit into
masterfrom
fix/mscmd-argument-quoting

Conversation

@salva

@salva salva commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Fix Net::OpenSSH::ShellQuoter::MSCmd so it preserves empty arguments and arguments containing spaces or tabs.

Changes

  • Keep the existing cmd metacharacter escaping.
  • Wrap empty and whitespace-containing arguments in double quotes after escaping.
  • Add focused unit tests for plain, empty, whitespace, metacharacter, and newline cases.
  • Add the new test file to MANIFEST.

Fixes #47.

Testing

  • perl -Ilib -c lib/Net/OpenSSH/ShellQuoter/MSCmd.pm
  • perl -Ilib t/mscmd-quoting.t

Copilot AI review requested due to automatic review settings June 4, 2026 11:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Net::OpenSSH::ShellQuoter::MSCmd so cmd.exe argument quoting preserves empty arguments and arguments containing spaces/tabs, preventing argument-vector corruption when remote_shell => 'MSCmd' is used.

Changes:

  • Update MSCmd->quote to wrap empty and whitespace-containing arguments in double quotes (after existing metacharacter escaping).
  • Add a focused unit test covering plain, whitespace, empty, metacharacter-escaping, and newline-rejection cases.
  • Include the new test in MANIFEST for packaging.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/Net/OpenSSH/ShellQuoter/MSCmd.pm Quotes empty/whitespace args to preserve argument boundaries while keeping existing cmd metacharacter escaping.
t/mscmd-quoting.t Adds unit coverage for the updated MSCmd quoting behavior and newline rejection.
MANIFEST Ensures the new test file is shipped in release tarballs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

MSCmd shell quoter does not preserve spaces or empty arguments

2 participants