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

std: Fix process spawn for arguments ending in backslashes on Windows #24820

Merged
merged 1 commit into from
Apr 27, 2015
Merged

std: Fix process spawn for arguments ending in backslashes on Windows #24820

merged 1 commit into from
Apr 27, 2015

Conversation

bradking
Copy link
Contributor

Fix make_command_line for the case of backslashes at the end of an
argument requiring quotes. We must encode the command and arguments
such that CommandLineToArgvW recovers them in the spawned process.
Simplify the logic by using a running count of backslashes as they
are encountered instead of looking ahead for quotes following them.

Extend test_make_command_line to additionally cover:

  • a leading quote in an argument that requires quotes,
  • a backslash before a quote in an argument that requires quotes,
  • a backslash at the end of an argument that requires quotes, and
  • a backslash at the end of an argument that does not require quotes.

Fix `make_command_line` for the case of backslashes at the end of an
argument requiring quotes.  We must encode the command and arguments
such that `CommandLineToArgvW` recovers them in the spawned process.
Simplify the logic by using a running count of backslashes as they
are encountered instead of looking ahead for quotes following them.

Extend `test_make_command_line` to additionally cover:

* a leading quote in an argument that requires quotes,
* a backslash before a quote in an argument that requires quotes,
* a backslash at the end of an argument that requires quotes, and
* a backslash at the end of an argument that does not require quotes.
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@alexcrichton
Copy link
Member

@bors: r+ e90408e

Thanks!

bors added a commit that referenced this pull request Apr 27, 2015
…e, r=alexcrichton

Fix `make_command_line` for the case of backslashes at the end of an
argument requiring quotes.  We must encode the command and arguments
such that `CommandLineToArgvW` recovers them in the spawned process.
Simplify the logic by using a running count of backslashes as they
are encountered instead of looking ahead for quotes following them.

Extend `test_make_command_line` to additionally cover:

* a leading quote in an argument that requires quotes,
* a backslash before a quote in an argument that requires quotes,
* a backslash at the end of an argument that requires quotes, and
* a backslash at the end of an argument that does not require quotes.
@bors
Copy link
Contributor

bors commented Apr 27, 2015

⌛ Testing commit e90408e with merge 5c60145...

@bors bors merged commit e90408e into rust-lang:master Apr 27, 2015
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.

5 participants