From 0bd05dbb3ba3a903375d9497da087dc4c8c7720b Mon Sep 17 00:00:00 2001 From: Al-Amin Firdows Date: Sat, 27 Jun 2026 08:43:34 +0600 Subject: [PATCH 1/3] fix: trim whitespace from --exclude parameter values The --exclude parameter for both wp core verify-checksums and wp plugin verify-checksums failed to handle comma-separated values with spaces. For example, --exclude="ai, plugin-check" would only exclude "ai" but not "plugin-check" due to the leading space in the trimmed value. Applied array_map('trim', explode(',', ...)) to normalize whitespace in both Checksum_Core_Command and Checksum_Plugin_Command. Added test cases for both commands to verify correct handling of space-separated exclude values. Fixes #154 --- features/checksum-core.feature | 16 ++++++++++++++++ features/checksum-plugin.feature | 24 ++++++++++++++++++++++++ src/Checksum_Core_Command.php | 2 +- src/Checksum_Plugin_Command.php | 2 +- 4 files changed, 42 insertions(+), 2 deletions(-) diff --git a/features/checksum-core.feature b/features/checksum-core.feature index 665d98cf..7f41d193 100644 --- a/features/checksum-core.feature +++ b/features/checksum-core.feature @@ -312,3 +312,19 @@ Feature: Validate checksums for WordPress install Success: WordPress installation verifies against checksums. """ And the return code should be 0 + + Scenario: Verify core checksums with excluded files containing spaces + Given a WP install + And "WordPress" replaced with "PressWord" in the readme.html file + And a wp-includes/some-filename.php file: + """ + sample content of some file + """ + + When I try `wp core verify-checksums --exclude='readme.html, wp-includes/some-filename.php'` + Then STDERR should be empty + And STDOUT should be: + """ + Success: WordPress installation verifies against checksums. + """ + And the return code should be 0 diff --git a/features/checksum-plugin.feature b/features/checksum-plugin.feature index 98920c6f..acc65d20 100644 --- a/features/checksum-plugin.feature +++ b/features/checksum-plugin.feature @@ -291,3 +291,27 @@ Feature: Validate checksums for WordPress plugins Warning: Must-use plugin 'custom-mu-plugin.php' appears to be a custom file or loader plugin and cannot be verified. """ And STDOUT should match /Success: Verified \d of \d plugins \(\d skipped\)\./ + + Scenario: Plugin verification is skipped when the --exclude argument contains spaces + Given a WP install + + When I run `wp plugin delete --all` + Then STDOUT should contain: + """ + Success: + """ + + When I run `wp plugin install akismet --ignore-requirements` + Then STDOUT should contain: + """ + Success: + """ + + When I run `wp plugin install duplicate-post --version=3.2.1 --ignore-requirements` + Then STDOUT should contain: + """ + Success: + """ + + When I try `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'` + Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./ diff --git a/src/Checksum_Core_Command.php b/src/Checksum_Core_Command.php index 8bca3518..5a956327 100644 --- a/src/Checksum_Core_Command.php +++ b/src/Checksum_Core_Command.php @@ -126,7 +126,7 @@ public function __invoke( $args, $assoc_args ) { if ( ! empty( $assoc_args['exclude'] ) ) { $exclude = Utils\get_flag_value( $assoc_args, 'exclude', '' ); - $this->exclude_files = explode( ',', $exclude ); + $this->exclude_files = array_map( 'trim', explode( ',', $exclude ) ); } if ( empty( $wp_version ) ) { diff --git a/src/Checksum_Plugin_Command.php b/src/Checksum_Plugin_Command.php index cf3f38f2..048be108 100644 --- a/src/Checksum_Plugin_Command.php +++ b/src/Checksum_Plugin_Command.php @@ -103,7 +103,7 @@ public function __invoke( $args, $assoc_args ) { WP_CLI::error( 'You need to specify either one or more plugin slugs to check or use the --all flag to check all plugins.' ); } - $exclude_list = explode( ',', $exclude ); + $exclude_list = array_map( 'trim', explode( ',', $exclude ) ); $skips = 0; From b2ed9faddabfa70ebfed426b3c40be6db36e5a3f Mon Sep 17 00:00:00 2001 From: Al-Amin Firdows Date: Mon, 29 Jun 2026 19:37:42 +0600 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- features/checksum-plugin.feature | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/features/checksum-plugin.feature b/features/checksum-plugin.feature index acc65d20..47855227 100644 --- a/features/checksum-plugin.feature +++ b/features/checksum-plugin.feature @@ -313,5 +313,8 @@ Feature: Validate checksums for WordPress plugins Success: """ - When I try `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'` - Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./ + When I run `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'` + Then STDOUT should be: + """ + Success: Verified 0 of 2 plugins (2 skipped). + """ From d9416a11142b2d862658cc0d8b642fefe0c2c8bf Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 30 Jun 2026 11:08:10 +0200 Subject: [PATCH 3/3] Revert "Potential fix for pull request finding" This reverts commit b2ed9faddabfa70ebfed426b3c40be6db36e5a3f. --- features/checksum-plugin.feature | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/features/checksum-plugin.feature b/features/checksum-plugin.feature index 47855227..acc65d20 100644 --- a/features/checksum-plugin.feature +++ b/features/checksum-plugin.feature @@ -313,8 +313,5 @@ Feature: Validate checksums for WordPress plugins Success: """ - When I run `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'` - Then STDOUT should be: - """ - Success: Verified 0 of 2 plugins (2 skipped). - """ + When I try `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'` + Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./