Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with chars in plugin name #642

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,17 @@
} 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_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' ),
$parser->name,
$plugin_data['Name']
$plugin_readme_name,
$plugin_header_name

Check warning on line 162 in includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php

View check run for this annotation

Codecov / codecov/patch

includes/Checker/Checks/Plugin_Repo/Plugin_Readme_Check.php#L161-L162

Added lines #L161 - L162 were not covered by tests
),
'mismatched_plugin_name',
$readme_file,
Expand Down
6 changes: 3 additions & 3 deletions tests/behat/features/plugin-check.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
<?php
/**
* Plugin Name: John's Post Counter
* Plugin Name: John's Post & Counter
*/

"""
And a wp-content/plugins/johns-post-counter/readme.txt file:
"""
=== John's Post Counter ===
=== John's Post & Counter ===
"""

When I run the WP-CLI command `plugin check johns-post-counter --format=csv --fields=code,type`
Expand Down