From f9ffc3446b9452bb26d5f69982ef10290d893c7f Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 18 Sep 2024 17:13:22 +0545 Subject: [PATCH 1/2] Issue with special chars in plugin name --- .../Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index 6308c37ec..e2bfa6f57 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -149,14 +149,17 @@ private function check_name( Check_Result $result, string $readme_file, Parser $ } else { $plugin_data = get_plugin_data( $result->plugin()->main_file() ); - if ( html_entity_decode( $parser->name, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ) !== $plugin_data['Name'] ) { + $plugin_readme_name = html_entity_decode( $parser->name, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ); + $plugin_header_name = html_entity_decode( $plugin_data['Name'], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ); + + if ( $plugin_name_readme !== $plugin_header_name ) { $this->add_result_warning_for_file( $result, sprintf( /* translators: 1: Plugin name, 2: Name in plugin header */ __( 'Plugin name "%1$s" is different from the name declared in plugin header "%2$s".', 'plugin-check' ), - $parser->name, - $plugin_data['Name'] + $plugin_name_readme, + $plugin_header_name ), 'mismatched_plugin_name', $readme_file, From 668ac74cbf084decf60e6e95d1c1fa05072a16ba Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Wed, 18 Sep 2024 17:16:42 +0545 Subject: [PATCH 2/2] Update test for special chars --- includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 4 ++-- tests/behat/features/plugin-check.feature | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index e2bfa6f57..121b912b2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -152,13 +152,13 @@ private function check_name( Check_Result $result, string $readme_file, Parser $ $plugin_readme_name = html_entity_decode( $parser->name, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ); $plugin_header_name = html_entity_decode( $plugin_data['Name'], ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401 ); - if ( $plugin_name_readme !== $plugin_header_name ) { + if ( $plugin_readme_name !== $plugin_header_name ) { $this->add_result_warning_for_file( $result, sprintf( /* translators: 1: Plugin name, 2: Name in plugin header */ __( 'Plugin name "%1$s" is different from the name declared in plugin header "%2$s".', 'plugin-check' ), - $plugin_name_readme, + $plugin_readme_name, $plugin_header_name ), 'mismatched_plugin_name', diff --git a/tests/behat/features/plugin-check.feature b/tests/behat/features/plugin-check.feature index 430c30cb0..be05e4699 100644 --- a/tests/behat/features/plugin-check.feature +++ b/tests/behat/features/plugin-check.feature @@ -116,19 +116,19 @@ Feature: Test that the WP-CLI command works. WordPress.Security.EscapeOutput.OutputNotEscaped """ - Scenario: Check plugin with apostrophe in plugin name + Scenario: Check plugin with special chars in plugin name Given a WP install with the Plugin Check plugin And a wp-content/plugins/johns-post-counter/johns-post-counter.php file: """