From d62141c38d307ff350da29b11bf4ba7d107d4954 Mon Sep 17 00:00:00 2001 From: "Dominik Schilling (ocean90)" Date: Sat, 30 Apr 2016 15:08:06 +0000 Subject: [PATCH] Plugins: In `plugin_basename()` normalize the file path before unresolving symlinks. `$wp_plugin_paths` contains normalized paths, see `wp_register_plugin_realpath()`. Props jdgrimes, voldemortensen, flyingdr, ocean90. Fixes #29154. git-svn-id: https://develop.svn.wordpress.org/trunk@37332 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/plugin.php | 4 ++- .../tests/functions/pluginBasename.php | 27 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/phpunit/tests/functions/pluginBasename.php diff --git a/src/wp-includes/plugin.php b/src/wp-includes/plugin.php index 7f6217dedf..3972b30621 100644 --- a/src/wp-includes/plugin.php +++ b/src/wp-includes/plugin.php @@ -675,13 +675,15 @@ function remove_all_actions($tag, $priority = false) { function plugin_basename( $file ) { global $wp_plugin_paths; + // $wp_plugin_paths contains normalized paths. + $file = wp_normalize_path( $file ); + foreach ( $wp_plugin_paths as $dir => $realdir ) { if ( strpos( $file, $realdir ) === 0 ) { $file = $dir . substr( $file, strlen( $realdir ) ); } } - $file = wp_normalize_path( $file ); $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR ); $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR ); diff --git a/tests/phpunit/tests/functions/pluginBasename.php b/tests/phpunit/tests/functions/pluginBasename.php new file mode 100644 index 0000000000..c7a90e23c3 --- /dev/null +++ b/tests/phpunit/tests/functions/pluginBasename.php @@ -0,0 +1,27 @@ +assertSame( 'a-symlinked-plugin/plugin.php', $basename ); + } +}