Make WordPress Core

Ticket #16953: 16953.3.diff

File 16953.3.diff, 2.9 KB (added by rmccue, 11 years ago)

First pass at using realpath to find symlinks

  • wp-includes/functions.php

    diff --git wp-includes/functions.php wp-includes/functions.php
    index c4dc1e7..6367dce 100644
    function path_join( $base, $path ) { 
    14291429}
    14301430
    14311431/**
     1432 * Normalize a filesystem path
     1433 *
     1434 * Replaces backslashes with forward slashes for Windows systems, and ensures
     1435 * no duplicate slashes exist.
     1436 *
     1437 * @param string $path Path to normalize
     1438 * @return string Normalized path
     1439 */
     1440function wp_normalize_path( $path ) {
     1441        $path = str_replace( '\\', '/', $file );
     1442        $path = preg_replace( '|/+|','/', $file );
     1443        return $path;
     1444}
     1445
     1446/**
    14321447 * Determines a writable directory for temporary files.
    14331448 * Function's preference is the return value of <code>sys_get_temp_dir()</code>,
    14341449 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
  • wp-includes/plugin.php

    diff --git wp-includes/plugin.php wp-includes/plugin.php
    index 03c4ac3..5da5c45 100644
    function remove_all_actions($tag, $priority = false) { 
    574574 * @uses WP_PLUGIN_DIR
    575575 */
    576576function plugin_basename($file) {
    577         $file = str_replace('\\','/',$file); // sanitize for Win32 installs
    578         $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
    579         $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
    580         $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
    581         $mu_plugin_dir = str_replace('\\','/',WPMU_PLUGIN_DIR); // sanitize for Win32 installs
    582         $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
     577        global $wp_plugin_paths;
     578        foreach ($wp_plugin_paths as $dir => $realdir) {
     579                if (strpos($file, $realdir) === 0) {
     580                        $file = $dir . substr( $file, strlen( $realdir ) );
     581                }
     582        }
     583
     584        $file = wp_normalize_path($file);
     585        $plugin_dir = wp_normalize_path( WP_PLUGIN_DIR );
     586        $mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
     587
    583588        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    584589        $file = trim($file, '/');
    585590        return $file;
  • wp-settings.php

    diff --git wp-settings.php wp-settings.php
    index 24aee93..2618326 100644
    create_initial_post_types(); 
    194194register_theme_directory( get_theme_root() );
    195195
    196196// Load active plugins.
    197 foreach ( wp_get_active_and_valid_plugins() as $plugin )
     197$wp_plugin_paths = array();
     198foreach ( wp_get_active_and_valid_plugins() as $plugin ) {
     199        $plugin_path = wp_normalize_path( dirname( $plugin ) );
     200        $plugin_realpath = wp_normalize_path( dirname( realpath( $plugin ) ) );
     201
     202        if ( $plugin_path !== $plugin_realpath ) {
     203                $wp_plugin_paths[ $plugin_path ] = $plugin_realpath;
     204        }
     205
    198206        include_once( $plugin );
    199 unset( $plugin );
     207}
     208unset( $plugin, $plugin_path, $plugin_realpath );
    200209
    201210// Load pluggable functions.
    202211require( ABSPATH . WPINC . '/pluggable.php' );