Skip to content

Drop escapeshellcmd() pass on tar command line - #132

Merged
swissspidy merged 1 commit into
mainfrom
fix/double-esc
Aug 3, 2026
Merged

Drop escapeshellcmd() pass on tar command line#132
swissspidy merged 1 commit into
mainfrom
fix/double-esc

Conversation

@swissspidy

@swissspidy swissspidy commented Aug 3, 2026

Copy link
Copy Markdown
Member

Follow-up to #131.

Overview

Utils\esc_cmd() safely single-quotes arguments passed to the shell. Calling $this->escapeshellcmd() on the output of esc_cmd() caused PHP's native escapeshellcmd() to insert backslashes before special characters (such as parentheses (, ), $, ;, etc.) inside single quotes '...'. In shell execution, backslashes inside single quotes are interpreted as literal backslashes, causing tar command line invocations to fail when project directory paths contain special characters.

Changes

  • Removed the $this->escapeshellcmd() pass prior to launching the tar process and removed the unused helper method.
  • Added a Behat test scenario verifying wp dist-archive runs cleanly on project paths containing parentheses.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed tarball generation for source directories whose names contain parentheses.
    • Archive creation now produces the expected escaped filename and successfully generates the archive.

Copilot AI review requested due to automatic review settings August 3, 2026 14:33
@swissspidy
swissspidy requested a review from a team as a code owner August 3, 2026 14:33
@swissspidy swissspidy added bug command:dist-archive Related to 'dist-archive' command labels Aug 3, 2026
@swissspidy swissspidy added this to the 3.2.3 milestone Aug 3, 2026
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fb6f0a38-6487-407a-a3ff-baf1ec1d025b

📥 Commits

Reviewing files that changed from the base of the PR and between 8fc93c6 and 57095b5.

📒 Files selected for processing (2)
  • features/dist-archive.feature
  • src/Dist_Archive_Command.php

📝 Walkthrough

Walkthrough

The tar archive command now passes directly to WP_CLI::launch(). The custom escaping helper was removed. A BDD scenario verifies tarball creation from a directory named plug(1).

Changes

Tar command handling

Layer / File(s) Summary
Direct tar launch and regression coverage
src/Dist_Archive_Command.php, features/dist-archive.feature
Tar commands bypass custom escaping and whitelist processing before WP_CLI::launch(). BDD coverage verifies creation of plug(1).1.0.0.tar.gz from the plug(1) directory.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: copilot

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: removing the redundant escapeshellcmd() pass from the tar command invocation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/double-esc

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 wp dist-archive tarball generation when the source directory path contains characters like parentheses by avoiding a second escaping pass that corrupts already-safely-quoted shell arguments.

Changes:

  • Removed the additional escapeshellcmd() pass before running the tar command and deleted the now-unused helper method.
  • Added a Behat acceptance scenario to ensure tarball generation succeeds when the project directory contains parentheses.

Reviewed changes

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

File Description
src/Dist_Archive_Command.php Launches the tar command using the Utils\esc_cmd() output directly (avoids introducing literal backslashes inside single-quoted args).
features/dist-archive.feature Adds acceptance coverage for running wp dist-archive on a directory name containing parentheses.

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

@swissspidy
swissspidy merged commit f478924 into main Aug 3, 2026
76 of 77 checks passed
@swissspidy
swissspidy deleted the fix/double-esc branch August 3, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug command:dist-archive Related to 'dist-archive' command

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants