From b00d094e34b9bdd42428fba39688df4ecd22714d Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 28 Jul 2026 22:22:59 +0200 Subject: [PATCH 1/2] Reject invalid `Requires at least` header values --- features/scaffold-plugin-tests.feature | 25 +++++++++++++++++++++++++ src/Scaffold_Command.php | 8 +++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/features/scaffold-plugin-tests.feature b/features/scaffold-plugin-tests.feature index b224dbd3..dc1fa76b 100644 --- a/features/scaffold-plugin-tests.feature +++ b/features/scaffold-plugin-tests.feature @@ -143,6 +143,31 @@ Feature: Scaffold plugin unit tests SKIP_DB_CREATE=true """ + Scenario: Scaffold plugin tests ignores invalid version in readme.txt + Given a WP install + And I run `wp scaffold plugin hello-world --skip-tests` + + When I run `wp plugin path hello-world --dir` + Then save STDOUT as {PLUGIN_DIR} + + Given a {PLUGIN_DIR}/readme.txt file: + """ + === Hello World === + Requires at least: 6.4; echo exploit # + Tested up to: 6.4 + """ + + When I run `wp scaffold plugin-tests hello-world --ci=circle` + Then STDOUT should not be empty + And the {PLUGIN_DIR}/.circleci/config.yml file should not contain: + """ + 6.4; echo exploit # + """ + And the {PLUGIN_DIR}/.circleci/config.yml file should contain: + """ + bash bin/install-wp-tests.sh wordpress_test root '' 127.0.0.1 latest $SKIP_DB_CREATE + """ + Scenario: Scaffold plugin tests with Gitlab as the provider Given a WP install And I run `wp scaffold plugin hello-world --skip-tests` diff --git a/src/Scaffold_Command.php b/src/Scaffold_Command.php index f1a3e6be..dc3441b1 100644 --- a/src/Scaffold_Command.php +++ b/src/Scaffold_Command.php @@ -893,9 +893,11 @@ private function scaffold_plugin_theme_tests( $args, $assoc_args, $type ) { if ( file_exists( "{$target_dir}/readme.txt" ) ) { $readme_content = (string) file_get_contents( "{$target_dir}/readme.txt" ); - preg_match( '/Requires at least\:(.*)\n/m', $readme_content, $matches ); - if ( isset( $matches[1] ) && $matches[1] ) { - $wp_versions_to_test[] = trim( $matches[1] ); + if ( preg_match( '/Requires at least\:(.*)(?:\r?\n|$)/i', $readme_content, $matches ) ) { + $version = trim( $matches[1] ); + if ( preg_match( '/^[0-9]+(?:\.[0-9]+)*(?:-[a-zA-Z0-9.]+)?$/', $version ) ) { + $wp_versions_to_test[] = $version; + } } } $wp_versions_to_test[] = 'latest'; From 1e89525763460755f800fe68fc7aef3fa4d14795 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Tue, 4 Aug 2026 17:47:41 +0200 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- features/scaffold-plugin-tests.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/scaffold-plugin-tests.feature b/features/scaffold-plugin-tests.feature index dc1fa76b..4376b8da 100644 --- a/features/scaffold-plugin-tests.feature +++ b/features/scaffold-plugin-tests.feature @@ -143,7 +143,7 @@ Feature: Scaffold plugin unit tests SKIP_DB_CREATE=true """ - Scenario: Scaffold plugin tests ignores invalid version in readme.txt + Scenario: Scaffold plugin tests ignore invalid version in readme.txt Given a WP install And I run `wp scaffold plugin hello-world --skip-tests`