mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Do not allow .. anywhere in the filename.
git-svn-id: https://develop.svn.wordpress.org/trunk@2019 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c5f6ac8cc4
commit
0215f2ba6a
@ -760,20 +760,37 @@ function add_management_page($page_title, $menu_title, $access_level, $file) {
|
||||
add_submenu_page('edit.php', $page_title, $menu_title, $access_level, $file);
|
||||
}
|
||||
|
||||
function validate_file_to_edit($file, $allowed_files = '') {
|
||||
if ('..' == substr($file,0,2))
|
||||
die (__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
|
||||
function validate_file($file, $allowed_files = '') {
|
||||
if ( false !== strpos($file, './'))
|
||||
return 1;
|
||||
|
||||
if (':' == substr($file,1,1))
|
||||
die (__('Sorry, can’t call files with their real path.'));
|
||||
return 2;
|
||||
|
||||
if ( !empty($allowed_files) && (! in_array($file, $allowed_files)) ) {
|
||||
die (__('Sorry, that file cannot be edited.'));
|
||||
}
|
||||
|
||||
if ( !empty($allowed_files) && (! in_array($file, $allowed_files)) )
|
||||
return 3;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
function validate_file_to_edit($file, $allowed_files = '') {
|
||||
$file = stripslashes($file);
|
||||
|
||||
return $file;
|
||||
$code = validate_file($file, $allowed_files);
|
||||
|
||||
if (! $code)
|
||||
return $file;
|
||||
|
||||
switch ($code) {
|
||||
case 1:
|
||||
die (__('Sorry, can’t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
|
||||
|
||||
case 2:
|
||||
die (__('Sorry, can’t call files with their real path.'));
|
||||
|
||||
case 3:
|
||||
die (__('Sorry, that file cannot be edited.'));
|
||||
}
|
||||
}
|
||||
|
||||
function get_home_path() {
|
||||
|
||||
@ -42,13 +42,15 @@ require(ABSPATH . '/wp-admin/menu.php');
|
||||
// Handle plugin admin pages.
|
||||
if (isset($_GET['page'])) {
|
||||
$plugin_page = plugin_basename($_GET['page']);
|
||||
if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page")) {
|
||||
die(sprintf(__('Cannot load %s.'), $plugin_page));
|
||||
if ( validate_file($plugin_page) ) {
|
||||
die(__('Invalid plugin page'));
|
||||
}
|
||||
|
||||
if (! isset($_GET['noheader'])) {
|
||||
if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page"))
|
||||
die(sprintf(__('Cannot load %s.'), $plugin_page));
|
||||
|
||||
if (! isset($_GET['noheader']))
|
||||
require_once(ABSPATH . '/wp-admin/admin-header.php');
|
||||
}
|
||||
|
||||
include(ABSPATH . "wp-content/plugins/$plugin_page");
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user