Skip to content

Document and fix command sanitizing with shlex.split#3245

Merged
Rowlando13 merged 1 commit intopallets:stablefrom
kdeldycke:no-shell-command
Apr 8, 2026
Merged

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

Conversation

@kdeldycke
Copy link
Copy Markdown
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

@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
@Rowlando13 Rowlando13 modified the milestones: 8.3.2, 8.3.3 Mar 15, 2026
Removes last use of `shell=True` use for command invokation for defense-in-depth.
Refs: pallets#1026, pallets#1477 and pallets#2775
@Rowlando13 Rowlando13 merged commit 63ea71f into pallets:stable Apr 8, 2026
12 checks passed
@kdeldycke kdeldycke deleted the no-shell-command branch April 9, 2026 08:48
@kdeldycke
Copy link
Copy Markdown
Collaborator Author

Thanks @Rowlando13 for the merge again ! 🎉

kdeldycke added a commit to kdeldycke/click that referenced this pull request Apr 9, 2026
Add missing entries for pallets#3238 and pallets#3299
Fix wrong version for pallets#3245 changelog entry
Lint section format
@kdeldycke
Copy link
Copy Markdown
Collaborator Author

There was a tiny issue with the location of the changelog entry for that PR that I fixed in 1339fd3 and moved it to the 8.3.3 section.

Comment thread src/click/_termui_impl.py
Comment thread src/click/_termui_impl.py
Comment thread src/click/_termui_impl.py
Comment thread src/click/_termui_impl.py
kdeldycke added a commit to kdeldycke/click that referenced this pull request Apr 10, 2026
Also move to Python comments details relevant to developers instead of docstrings
Follow up to pallets#3245
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.

3 participants