Skip to content

Commit 6dd1167

Browse files
alaminfirdowsCopilotswissspidy
authored
fix: trim whitespace from --exclude parameter values (#155)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Pascal Birchler <pascalb@google.com>
1 parent fa2feec commit 6dd1167

4 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎features/checksum-core.feature‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,19 @@ Feature: Validate checksums for WordPress install
312312
Success: WordPress installation verifies against checksums.
313313
"""
314314
And the return code should be 0
315+
316+
Scenario: Verify core checksums with excluded files containing spaces
317+
Given a WP install
318+
And "WordPress" replaced with "PressWord" in the readme.html file
319+
And a wp-includes/some-filename.php file:
320+
"""
321+
sample content of some file
322+
"""
323+
324+
When I try `wp core verify-checksums --exclude='readme.html, wp-includes/some-filename.php'`
325+
Then STDERR should be empty
326+
And STDOUT should be:
327+
"""
328+
Success: WordPress installation verifies against checksums.
329+
"""
330+
And the return code should be 0

‎features/checksum-plugin.feature‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,27 @@ Feature: Validate checksums for WordPress plugins
291291
Warning: Must-use plugin 'custom-mu-plugin.php' appears to be a custom file or loader plugin and cannot be verified.
292292
"""
293293
And STDOUT should match /Success: Verified \d of \d plugins \(\d skipped\)\./
294+
295+
Scenario: Plugin verification is skipped when the --exclude argument contains spaces
296+
Given a WP install
297+
298+
When I run `wp plugin delete --all`
299+
Then STDOUT should contain:
300+
"""
301+
Success:
302+
"""
303+
304+
When I run `wp plugin install akismet --ignore-requirements`
305+
Then STDOUT should contain:
306+
"""
307+
Success:
308+
"""
309+
310+
When I run `wp plugin install duplicate-post --version=3.2.1 --ignore-requirements`
311+
Then STDOUT should contain:
312+
"""
313+
Success:
314+
"""
315+
316+
When I try `wp plugin verify-checksums --all --exclude='akismet, duplicate-post'`
317+
Then STDOUT should match /^Success: Verified \d of \d plugins \(\d skipped\)\./

‎src/Checksum_Core_Command.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function __invoke( $args, $assoc_args ) {
126126
if ( ! empty( $assoc_args['exclude'] ) ) {
127127
$exclude = Utils\get_flag_value( $assoc_args, 'exclude', '' );
128128

129-
$this->exclude_files = explode( ',', $exclude );
129+
$this->exclude_files = array_map( 'trim', explode( ',', $exclude ) );
130130
}
131131

132132
if ( empty( $wp_version ) ) {

‎src/Checksum_Plugin_Command.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function __invoke( $args, $assoc_args ) {
103103
WP_CLI::error( 'You need to specify either one or more plugin slugs to check or use the --all flag to check all plugins.' );
104104
}
105105

106-
$exclude_list = explode( ',', $exclude );
106+
$exclude_list = array_map( 'trim', explode( ',', $exclude ) );
107107

108108
$skips = 0;
109109

0 commit comments

Comments
 (0)