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

Windows shlex fix #2895

Merged
merged 5 commits into from Jan 25, 2023
Merged

Windows shlex fix #2895

merged 5 commits into from Jan 25, 2023

Conversation

masenf
Copy link
Collaborator

@masenf masenf commented Jan 25, 2023

When parsing command lines, use shlex(..., posix=True), even on windows platforms, since non-POSIX mode does not handle escape characters and quoting like a shell would. This improves cross-platform configurations without hacks or esoteric quoting.

To make this transition easier, on Windows, the backslash path separator will not treated as an escape character unless it preceeds a quote, whitespace, or another backslash chracter. This allows paths to mostly be written in single or double backslash style.

Note that double-backslash will no longer be escaped to a single backslash in substitutions, instead the double backslash will be consumed as part of command splitting, on either posix or windows platforms.

In some instances superfluous double or single quote characters may be stripped from arg arrays in ways that do not occur in the default windows cmd.exe shell.

TODO

Ensure this does not regress #2732 and other recent fixes around the substitution parser.

Thanks for contribution

Please, make sure you address all the checklists (for details on how see
development documentation)!

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

however the double backslash _is_ special in that in prevents the 2nd backslash
from escaping the following character. the reason for this is to allow shlex to
consume the double backslash during command splitting.
for less surprises, stick to shlex POSIX mode, regardless of the running platform.

on win32 platforms, explicitly convert a single backslash to double backslash,
unless the following character is "special"

fix tox-dev#2635

str_convert fixup

str_convert: always use shlex POSIX mode

for less surprises, stick to shlex POSIX mode, regardless of the running platform.

on win32 platforms, explicitly convert a single backslash to double backslash,
unless the following character is "special"

fix tox-dev#2635

str_convert fixup
export SubRequest from tox.pytest

add return type annotation to test fixture
Add a note that backslashes remaining in the string after substitution will be
handled by shlex, noting platform-specific difference.
@gaborbernat gaborbernat marked this pull request as ready for review January 25, 2023 20:23
@gaborbernat gaborbernat merged commit ea12bf4 into tox-dev:main Jan 25, 2023
descope bot added a commit to descope/django-descope that referenced this pull request Feb 8, 2023
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [tox](https://togithub.com/tox-dev/tox)
([changelog](https://tox.wiki/en/latest/changelog.html)) | dev | minor |
`4.3.5` -> `4.4.0` | `4.4.5` (+4) |

---

### Release Notes

<details>
<summary>tox-dev/tox</summary>

### [`v4.4.0`](https://togithub.com/tox-dev/tox/releases/tag/4.4.0)

[Compare Source](https://togithub.com/tox-dev/tox/compare/4.3.5...4.4.0)

#### What's Changed

- Add more explanation to `list_dependencies_command` configuration
option by [@&#8203;Czaki](https://togithub.com/Czaki) in
[tox-dev/tox#2883
- \[pre-commit.ci] pre-commit autoupdate by
[@&#8203;pre-commit-ci](https://togithub.com/pre-commit-ci) in
[tox-dev/tox#2889
- Enforce constraints during install_package_deps by
[@&#8203;masenf](https://togithub.com/masenf) in
[tox-dev/tox#2888
- Windows shlex fix by [@&#8203;masenf](https://togithub.com/masenf) in
[tox-dev/tox#2895

#### New Contributors

- [@&#8203;Czaki](https://togithub.com/Czaki) made their first
contribution in
[tox-dev/tox#2883

**Full Changelog**: tox-dev/tox@4.3.5...4.4.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMDEuMCIsInVwZGF0ZWRJblZlciI6IjM0LjEwMS4wIn0=-->

Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants