This commit is contained in:
2020-07-13 17:09:59 +02:00
parent 03559a7b76
commit 3a082e23cc
492 changed files with 4129 additions and 982 deletions
+7 -1
View File
@@ -681,11 +681,17 @@ function drupal_valid_test_ua($new_prefix = NULL) {
// Ensure that no information leaks on production sites.
$test_db = new TestDatabase($prefix);
$key_file = DRUPAL_ROOT . '/' . $test_db->getTestSitePath() . '/.htkey';
if (!is_readable($key_file)) {
if (!is_readable($key_file) || is_dir($key_file)) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
}
$private_key = file_get_contents($key_file);
// The string from drupal_generate_test_ua() is 74 bytes long. If we don't
// have it, tests cannot be allowed.
if (empty($private_key) || strlen($private_key) < 74) {
header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
exit;
}
// The file properties add more entropy not easily accessible to others.
$key = $private_key . filectime(__FILE__) . fileinode(__FILE__);
$time_diff = REQUEST_TIME - $time;
+2 -2
View File
@@ -683,7 +683,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
// http://php.net/manual/security.filesystem.nullbytes.php
$filename = str_replace(chr(0), '', $filename);
$whitelist = array_unique(explode(' ', strtolower(trim($extensions))));
$allowed_extensions = array_unique(explode(' ', strtolower(trim($extensions))));
// Split the filename up by periods. The first part becomes the basename
// the last part the final extension.
@@ -698,7 +698,7 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
// of allowed extensions.
foreach ($filename_parts as $filename_part) {
$new_filename .= '.' . $filename_part;
if (!in_array(strtolower($filename_part), $whitelist) && preg_match("/^[a-zA-Z]{2,5}\d?$/", $filename_part)) {
if (!in_array(strtolower($filename_part), $allowed_extensions) && preg_match("/^[a-zA-Z]{2,5}\d?$/", $filename_part)) {
$new_filename .= '_';
}
}
+1 -1
View File
@@ -1023,7 +1023,7 @@ function install_display_output($output, $install_state) {
// Prevent install.php from being indexed when installed in a sub folder.
// robots.txt rules are not read if the site is within domain.com/subfolder
// resulting in /subfolder/install.php being found through search engines.
// When settings.php is writeable this can be used via an external database
// When settings.php is writable this can be used via an external database
// leading a malicious user to gain php access to the server.
$noindex_meta_tag = [
'#tag' => 'meta',
+2
View File
@@ -478,6 +478,7 @@ function _drupal_rewrite_settings_global(&$ref, $variable) {
* The container for variable values.
* @param string $variable_name
* Name of variable.
*
* @return string
* A string containing valid PHP code of the variable suitable for placing
* into settings.php.
@@ -508,6 +509,7 @@ function _drupal_rewrite_settings_dump($variable, $variable_name) {
* A string to prepend to the variable's value.
* @param string $suffix
* A string to append to the variable's value.
*
* @return string
* A string containing valid PHP code of the variable suitable for placing
* into settings.php.