From 86b43a45b5051a1893e43608f5570a9b766d4baa Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 6 Dec 2024 10:19:20 +0100 Subject: [PATCH 1/5] escape mesage --- includes/CLI/Plugin_Check_Command.php | 1 + includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/CLI/Plugin_Check_Command.php b/includes/CLI/Plugin_Check_Command.php index 4c502d332..3510091f8 100644 --- a/includes/CLI/Plugin_Check_Command.php +++ b/includes/CLI/Plugin_Check_Command.php @@ -555,6 +555,7 @@ private function flatten_file_results( $file_errors, $file_warnings ) { foreach ( $column_errors as $column_error ) { $column_error['message'] = str_replace( array( '
', '', '', '', '' ), array( ' ', '', '', '`', '`' ), $column_error['message'] ); + $column_error['message'] = html_entity_decode( $column_error['message'] ); $file_results[] = array_merge( $column_error, diff --git a/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php b/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php index 8c98e01a1..422eb1bb6 100644 --- a/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php +++ b/includes/Checker/Checks/Abstract_PHP_CodeSniffer_Check.php @@ -142,7 +142,7 @@ final public function run( Check_Result $result ) { $this->add_result_message_for_file( $result, strtoupper( $file_message['type'] ) === 'ERROR', - $file_message['message'], + esc_html( $file_message['message'] ), $file_message['source'], $file_name, $file_message['line'], From e9478e8b3c3bc142d33b9e60932e336a9234abe5 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 6 Dec 2024 10:25:45 +0100 Subject: [PATCH 2/5] changed --- includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php index 98fc974d8..5badf8bd2 100644 --- a/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php +++ b/includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php @@ -213,7 +213,7 @@ private function check_headers( Check_Result $result, string $readme_file, Parse $result, sprintf( /* translators: 1: currently used version, 2: latest stable WordPress version, 3: 'Tested up to' */ - __( 'Tested up to: %1$s < %2$s.
The "%3$s" value in your plugin is not set to the current version of WordPress. This means your plugin will not show up in searches, as we require plugins to be compatible and documented as tested up to the most recent version of WordPress.', 'plugin-check' ), + __( 'Tested up to: %1$s < %2$s.
The "%3$s" value in your plugin is not set to the current version of WordPress. This means your plugin will not show up in searches, as we require plugins to be compatible and documented as tested up to the most recent version of WordPress.', 'plugin-check' ), $parser->{$field_key}, $latest_wordpress_version, 'Tested up to' From c5e3bdc910b35cdd1bf852328b02964d0e925dec Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 6 Dec 2024 10:37:14 +0100 Subject: [PATCH 3/5] updated tests --- .../phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php index cf53b5544..c8540365f 100644 --- a/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php @@ -58,8 +58,8 @@ public function test_run_without_default_textdomain() { // Explicitly using the 'default' text domain is a warning, omitting a text domain is an error. $this->assertNotEmpty( $check_result->get_errors() ); - $this->assertNotEmpty( $check_result->get_warnings() ); - $this->assertEquals( 1, $check_result->get_error_count() ); - $this->assertEquals( 1, $check_result->get_warning_count() ); + $this->assertEmpty( $check_result->get_warnings() ); + $this->assertEquals( 2, $check_result->get_error_count() ); + $this->assertEquals( 0, $check_result->get_warning_count() ); } } From 2ce79b0255a4ee231c0ba7f2506c0bd7cf17a4a3 Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 6 Dec 2024 11:09:51 +0100 Subject: [PATCH 4/5] reverted tests and updated escaped default --- includes/Checker/Checks/General/I18n_Usage_Check.php | 2 +- .../phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/Checker/Checks/General/I18n_Usage_Check.php b/includes/Checker/Checks/General/I18n_Usage_Check.php index eaba6541e..f7200f30b 100644 --- a/includes/Checker/Checks/General/I18n_Usage_Check.php +++ b/includes/Checker/Checks/General/I18n_Usage_Check.php @@ -99,7 +99,7 @@ public function get_documentation_url(): string { */ protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) { // Downgrade errors about usage of the 'default' text domain from WordPress Core to warnings. - if ( $error && str_ends_with( $message, " but got 'default'." ) ) { + if ( $error && str_ends_with( $message, " but got 'default'." ) ) { $error = false; } diff --git a/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php b/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php index c8540365f..cf53b5544 100644 --- a/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php +++ b/tests/phpunit/tests/Checker/Checks/I18n_Usage_Check_Tests.php @@ -58,8 +58,8 @@ public function test_run_without_default_textdomain() { // Explicitly using the 'default' text domain is a warning, omitting a text domain is an error. $this->assertNotEmpty( $check_result->get_errors() ); - $this->assertEmpty( $check_result->get_warnings() ); - $this->assertEquals( 2, $check_result->get_error_count() ); - $this->assertEquals( 0, $check_result->get_warning_count() ); + $this->assertNotEmpty( $check_result->get_warnings() ); + $this->assertEquals( 1, $check_result->get_error_count() ); + $this->assertEquals( 1, $check_result->get_warning_count() ); } } From 94403140428a559511171039b7b2e514cab9107d Mon Sep 17 00:00:00 2001 From: davidperezgar Date: Fri, 6 Dec 2024 11:13:06 +0100 Subject: [PATCH 5/5] fix phplint --- includes/Checker/Checks/General/I18n_Usage_Check.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Checker/Checks/General/I18n_Usage_Check.php b/includes/Checker/Checks/General/I18n_Usage_Check.php index f7200f30b..3678c3758 100644 --- a/includes/Checker/Checks/General/I18n_Usage_Check.php +++ b/includes/Checker/Checks/General/I18n_Usage_Check.php @@ -99,7 +99,7 @@ public function get_documentation_url(): string { */ protected function add_result_message_for_file( Check_Result $result, $error, $message, $code, $file, $line = 0, $column = 0, string $docs = '', $severity = 5 ) { // Downgrade errors about usage of the 'default' text domain from WordPress Core to warnings. - if ( $error && str_ends_with( $message, " but got 'default'." ) ) { + if ( $error && str_ends_with( $message, ' but got 'default'.' ) ) { $error = false; }