From 21755bf5bec2ef6bf52eaab23218aada48335950 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 27 Nov 2024 10:27:59 +0545 Subject: [PATCH] Update regex for version validation --- .../Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php | 4 ++-- .../plugins/test-plugin-late-escaping-errors/load.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php index 591683ba4..2ec651898 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Header_Fields_Check.php @@ -186,12 +186,12 @@ public function run( Check_Result $result ) { 7 ); } else { - if ( preg_match( '|[^\d\.]|', $plugin_header['Version'] ) ) { + if ( ! preg_match( '/^[a-z0-9.-]+$/i', $plugin_header['Version'] ) ) { $this->add_result_error_for_file( $result, sprintf( /* translators: %s: plugin header field */ - __( 'The "%s" header in the plugin file should only contain numeric and period characters.', 'plugin-check' ), + __( 'The "%s" header in the plugin file should only contain numbers, letters, periods, and hyphens.', 'plugin-check' ), esc_html( $labels['Version'] ) ), 'plugin_header_invalid_plugin_version', diff --git a/tests/phpunit/testdata/plugins/test-plugin-late-escaping-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-late-escaping-errors/load.php index 3f3a05b1f..d524bcddc 100644 --- a/tests/phpunit/testdata/plugins/test-plugin-late-escaping-errors/load.php +++ b/tests/phpunit/testdata/plugins/test-plugin-late-escaping-errors/load.php @@ -4,7 +4,7 @@ * Plugin URI: https://github.com/WordPress/plugin-check * Requires at least: 6.0 * Requires PHP: 5.6 - * Version: 1.0.0-Beta + * Version: 1.0.0 Beta * Author: WordPress Performance Team * Author URI: https://github.com/wordpress/plugin-check/ * License: GPLv2 or later