Skip to content

Document and fix command sanitizing with shlex.split#3245

Open
kdeldycke wants to merge 1 commit intopallets:stablefrom
kdeldycke:no-shell-command
Open

Document and fix command sanitizing with shlex.split#3245
kdeldycke wants to merge 1 commit intopallets:stablefrom
kdeldycke:no-shell-command

Conversation

@kdeldycke
Copy link
Collaborator

@kdeldycke kdeldycke commented Mar 5, 2026

Also removes last use of shell=True use for command invokation for defense-in-depth.

Context

I was trying to eliminate the last usage of shell=True in subprocess.Popen, then had to resort to using shlex.split in edit_files. This led me into the rabbit hole of shlex.split usage in _termui_impl.py file. Which I use as an opportunity to document past choices from older issues and PRs.

Tests

I also use that opportunity to collect test cases discussed in older related issues and PRs to illustrate and cover how we are expecting command path to be unquoted and interpreted on POSIX systems and Windows.

Related

Removes last use of `shell=True` use for command invokation for defense-in-depth.
Refs: pallets#1026, pallets#1477 and pallets#2775
@kdeldycke kdeldycke added this to the 8.3.2 milestone Mar 5, 2026
@kdeldycke kdeldycke added bug f:prompt feature: prompt for input labels Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug f:prompt feature: prompt for input

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant