Ticket #3882: 3882.diff

File 3882.diff, 4.3 kB (added by foolswisdom, 2 years ago)

trunk diff based on josegonzalez attached tiny_mce_gzip.php

  • wp-includes/js/tinymce/tiny_mce_gzip.php

    old new  
    1717 
    1818// gzip_compression(); 
    1919 
     20// New realpath function 
     21{ 
     22   if ($path == "") 
     23   { 
     24       return false; 
     25   } 
     26 
     27   $path = trim(preg_replace("/\\\\/", "/", (string)$path)); 
     28 
     29   if (!preg_match("/(\.\w{1,4})$/", $path)  &&  
     30       !preg_match("/\?[^\\/]+$/", $path)  &&  
     31       !preg_match("/\\/$/", $path)) 
     32   { 
     33       $path .= '/'; 
     34   } 
     35 
     36   $pattern = "/^(\\/|\w:\\/|https?:\\/\\/[^\\/]+\\/)?(.*)$/i"; 
     37 
     38   preg_match_all($pattern, $path, $matches, PREG_SET_ORDER); 
     39 
     40   $path_tok_1 = $matches[0][1]; 
     41   $path_tok_2 = $matches[0][2]; 
     42 
     43   $path_tok_2 = preg_replace( 
     44                   array("/^\\/+/", "/\\/+/"), 
     45                   array("", "/"), 
     46                   $path_tok_2); 
     47 
     48   $path_parts = explode("/", $path_tok_2); 
     49   $real_path_parts = array(); 
     50 
     51   for ($i = 0, $real_path_parts = array(); $i < count($path_parts); $i++) 
     52   { 
     53       if ($path_parts[$i] == '.') 
     54       { 
     55           continue; 
     56       } 
     57       else if ($path_parts[$i] == '..') 
     58       { 
     59           if (  (isset($real_path_parts[0])  &&  $real_path_parts[0] != '..') 
     60               || ($path_tok_1 != "")  ) 
     61           { 
     62               array_pop($real_path_parts); 
     63               continue; 
     64           } 
     65       } 
     66 
     67       array_push($real_path_parts, $path_parts[$i]); 
     68   } 
     69 
     70   return $path_tok_1 . implode('/', $real_path_parts); 
     71} 
     72 
     73// End of real_path function 
     74 
    2075function wp_tinymce_lang($path) { 
    2176        global $language; 
    2277 
    2378        $text = ''; 
    2479 
    2580        // Look for xx_YY.js, xx_yy.js, xx.js 
    26         $file = realpath(sprintf($path, $language)); 
     81        $file = real_path(sprintf($path, $language)); 
    2782        if ( file_exists($file) ) 
    2883                $text = file_get_contents($file); 
    29         $file = realpath(sprintf($path, strtolower($language))); 
     84        $file = real_path(sprintf($path, strtolower($language))); 
    3085        if ( file_exists($file) ) 
    3186                $text = file_get_contents($file); 
    32         $file = realpath(sprintf($path, substr($language, 0, 2))); 
     87        $file = real_path(sprintf($path, substr($language, 0, 2))); 
    3388        if ( file_exists($file) ) 
    3489                $text = file_get_contents($file); 
    3590 
    3691 
    3792        // Fall back on en.js 
    38         $file = realpath(sprintf($path, 'en')); 
     93        $file = real_path(sprintf($path, 'en')); 
    3994        if ( empty($text) && file_exists($file) ) 
    4095                $text = file_get_contents($file); 
    4196 
     
    78133$suffix = "";                                                   // Set to "_src" to use source version 
    79134$expiresOffset = 3600 * 24 * 10;                // 10 days util client cache expires 
    80135$diskCache = false;                                             // If you enable this option gzip files will be cached on disk. 
    81 $cacheDir = realpath(".");                            // Absolute directory path to where cached gz files will be stored 
     136$cacheDir = real_path(".");                           // Absolute directory path to where cached gz files will be stored 
    82137$debug = false;                                                 // Enable this option if you need debuging info 
    83138 
    84139// Headers 
     
    143198} else 
    144199        $diskCache = false; 
    145200 
     201 
    146202if ($index > -1) { 
    147203        // Write main script and patch some things 
    148204        if ($index == 0) { 
    149                 TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("tiny_mce" . $suffix . ".js")))); // WP 
     205                TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(real_path("tiny_mce" . $suffix . ".js")))); // WP 
    150206                TinyMCE_echo('TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;'); 
    151207                TinyMCE_echo('TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;'); 
    152208        } else 
     
    161217 
    162218        // Load theme, language pack and theme language packs 
    163219        if ($theme) { 
    164                 TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template" . $suffix . ".js")))); // WP 
     220                TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(real_path("themes/" . $theme . "/editor_template" . $suffix . ".js")))); // WP 
    165221                TinyMCE_echo(wp_tinymce_lang("themes/" . $theme . "/langs/%s.js")); // WP 
    166222        } 
    167223 
     
    171227        // Load all plugins and their language packs 
    172228        $plugins = explode(",", $plugins); 
    173229        foreach ($plugins as $plugin) { 
    174                 $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 
     230                $pluginFile = real_path("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js"); 
    175231                /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */ 
    176232 
    177233                if ($pluginFile)