WordPress.org

Make WordPress Core

Ticket #16953: WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.2.patch

File WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.2.patch, 1.8 KB (added by augustash, 7 years ago)
  • WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.patch

    diff --git a/WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.patch b/WP_fix_for_plugin_basename_to_allow_symlinks_2011-07-28.patch
    index 95e39fc..e69de29 100644
    a b  
    1 diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
    2 index 945461c..5bc475d 100644
    3 --- a/wp-includes/plugin.php
    4 +++ b/wp-includes/plugin.php
    5 @@ -567,7 +567,11 @@ function plugin_basename($file) {
    6         $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
    7         $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
    8         $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    9 -       $file = trim($file, '/');
    10 +       
    11 +       $dir      = basename(dirname($file));
    12 +       $filename = basename($file);
    13 +
    14 +       $file = trim($dir . '/' . $filename, '/');
    15         return $file;
    16  }
    17  
  • wp-includes/plugin.php

    diff --git a/wp-includes/plugin.php b/wp-includes/plugin.php
    index 5bc475d..5b5e693 100644
    a b function plugin_basename($file) { 
    568568        $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
    569569        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    570570       
    571         $dir      = basename(dirname($file));
    572         $filename = basename($file);
     571  $dir      = basename(dirname($file));
     572  $filename = basename($file);
     573  $filepath = ($dir == '.') ?  $filename : $dir . '/' . $filename;
     574 
     575  $file =  trim($filepath, '/');
    573576
    574         $file = trim($dir . '/' . $filename, '/');
    575577        return $file;
    576578}
    577579