Skip to content

Replace eval() in extract_subdir_path() with safe recursive path parser#6310

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/avoid-eval-in-extract-subdir-path
Draft

Replace eval() in extract_subdir_path() with safe recursive path parser#6310
Copilot wants to merge 4 commits intomainfrom
copilot/avoid-eval-in-extract-subdir-path

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 27, 2026

  • Replace eval() in Runner::extract_subdir_path() with a safe path expression parser
  • Add RunnerTest.php PHPUnit tests (17 cases)
  • Add Behat acceptance tests for dirname(__FILE__) and __DIR__ variants
  • Fix failing Behat test: <?php require __DIR__ on one line breaks the ^\s*require regex — removed <?php prefix to match the pattern used by the other test cases

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 74.75728% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
php/WP_CLI/Runner.php 74.75% 26 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copilot AI and others added 2 commits April 27, 2026 12:36
Copilot AI changed the title [WIP] Refactor extract_subdir_path to avoid eval usage in WP-CLI Replace eval() in extract_subdir_path() with safe recursive path parser Apr 27, 2026
Copilot AI requested a review from swissspidy April 27, 2026 12:40
@swissspidy

This comment was marked as resolved.

…IR__ test case

Agent-Logs-Url: https://github.com/wp-cli/wp-cli/sessions/32198f81-4601-4fa9-8363-645dc3851c24

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

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.

Avoid use of eval() in extract_subdir_path() during WordPress root detection

2 participants