WordPress.org

Make WordPress Core

Opened 2 years ago

#42670 new defect (bug)

Symlinked plugin makes plugin_basename function return wrong basename

Reported by: sergiienko Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.9
Component: Plugins Keywords:
Focuses: Cc:
PR Number:

Description

Symlinked plugin makes plugin_basename function return wrong basename for plugins which goes after the symlinked plugin. If symlinked plugin name is substring of WP root directory name.

For instance, plugin name is feedback-plugin and WP root directory is feedback-plugin-wp.

Cause of such a behavior is condition:

// wp-includes/plugin.php plugin_basename function (line 658).
if ( strpos( $file, $realdir ) === 0 ) {
    $file = $dir . substr( $file, strlen( $realdir ) );
}

Solution:

$pattern = '/^' . str_replace('/', '\/', $realdir) . '\//';
if ( preg_match( $pattern, $file ) ) {
    $file = $dir . substr( $file, strlen( $realdir ) );
}

Change History (0)

Note: See TracTickets for help on using tickets.