Skip to content

Commit f5c29c0

Browse files
Pantheon Automationpwtyler
Pantheon Automation
authored andcommitted
Update to Drupal 7.98. For more information, see https://www.drupal.org/project/drupal/releases/7.98
1 parent fc0521a commit f5c29c0

38 files changed

+733
-89
lines changed

CHANGELOG.txt

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Drupal 7.98, 2023-06-07
2+
-----------------------
3+
- Various security improvements
4+
- Various bug fixes, optimizations and improvements
5+
16
Drupal 7.97, 2023-04-21
27
-----------------------
38
- Fix PHP 5.x regression caused by SA-CORE-2023-005

cron.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
1414
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
1515

16-
if (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
17-
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
18-
drupal_access_denied();
19-
}
20-
elseif (variable_get('maintenance_mode', 0)) {
16+
if (variable_get('maintenance_mode', 0)) {
2117
watchdog('cron', 'Cron could not run because the site is in maintenance mode.', array(), WATCHDOG_NOTICE);
18+
drupal_site_offline();
19+
}
20+
elseif (!isset($_GET['cron_key']) || variable_get('cron_key', 'drupal') != $_GET['cron_key']) {
21+
watchdog('cron', 'Cron could not run because an invalid key was used.', array(), WATCHDOG_NOTICE);
2222
drupal_access_denied();
2323
}
2424
else {

includes/bootstrap.inc

+21-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* The current system version.
1010
*/
11-
define('VERSION', '7.97');
11+
define('VERSION', '7.98');
1212

1313
/**
1414
* Core API compatibility.
@@ -2328,15 +2328,30 @@ function drupal_base64_encode($string) {
23282328
/**
23292329
* Returns a string of highly randomized bytes (over the full 8-bit range).
23302330
*
2331-
* This function is better than simply calling mt_rand() or any other built-in
2332-
* PHP function because it can return a long string of bytes (compared to < 4
2333-
* bytes normally from mt_rand()) and uses the best available pseudo-random
2334-
* source.
2331+
* On PHP 7 and later, this function is a wrapper around the built-in PHP
2332+
* function random_bytes(). If that function does not exist or cannot find an
2333+
* appropriate source of randomness, this function is better than simply calling
2334+
* mt_rand() or any other built-in PHP function because it can return a long
2335+
* string of bytes (compared to < 4 bytes normally from mt_rand()) and uses the
2336+
* best available pseudo-random source.
23352337
*
2336-
* @param $count
2338+
* @param int $count
23372339
* The number of characters (bytes) to return in the string.
2340+
*
2341+
* @return string
2342+
* A randomly generated string.
23382343
*/
23392344
function drupal_random_bytes($count) {
2345+
if (function_exists('random_bytes')) {
2346+
try {
2347+
return random_bytes($count);
2348+
}
2349+
catch (Exception $e) {
2350+
// An appropriate source of randomness could not be found. Fall back to a
2351+
// less secure implementation.
2352+
}
2353+
}
2354+
23402355
// $random_state does not use drupal_static as it stores random bytes.
23412356
static $random_state, $bytes, $has_openssl;
23422357

includes/common.inc

+7
Original file line numberDiff line numberDiff line change
@@ -7380,6 +7380,13 @@ function _drupal_schema_initialize(&$schema, $module, $remove_descriptions = TRU
73807380
unset($field['description']);
73817381
}
73827382
}
7383+
// Set the type key for all fields where it is not set (mostly when using
7384+
// datatabase specific data types).
7385+
foreach ($table['fields'] as &$field) {
7386+
if (!isset($field['type'])) {
7387+
$field['type'] = NULL;
7388+
}
7389+
}
73837390
}
73847391
}
73857392

includes/file.inc

+11-5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ define('FILE_EXISTS_ERROR', 2);
6969
*/
7070
define('FILE_STATUS_PERMANENT', 1);
7171

72+
/**
73+
* A pipe-separated list of insecure extensions.
74+
*
75+
* @see file_munge_filename(), file_save_upload()
76+
*/
77+
define('FILE_INSECURE_EXTENSIONS', 'php|phar|pl|py|cgi|asp|js|phtml');
78+
7279
/**
7380
* Provides Drupal stream wrapper registry.
7481
*
@@ -1184,9 +1191,8 @@ function file_munge_filename($filename, $extensions, $alerts = TRUE) {
11841191

11851192
$whitelist = array_unique(explode(' ', strtolower(trim($extensions))));
11861193

1187-
// Remove unsafe extensions from the list of allowed extensions. The list is
1188-
// copied from file_save_upload().
1189-
$whitelist = array_diff($whitelist, explode('|', 'php|phar|pl|py|cgi|asp|js'));
1194+
// Remove unsafe extensions from the list of allowed extensions.
1195+
$whitelist = array_diff($whitelist, explode('|', FILE_INSECURE_EXTENSIONS));
11901196

11911197
// Split the filename up by periods. The first part becomes the basename
11921198
// the last part the final extension.
@@ -1566,7 +1572,7 @@ function file_save_upload($form_field_name, $validators = array(), $destination
15661572
// rename filename.php.foo and filename.php to filename.php_.foo_.txt and
15671573
// filename.php_.txt, respectively). Don't rename if 'allow_insecure_uploads'
15681574
// evaluates to TRUE.
1569-
if (preg_match('/\.(php|phar|pl|py|cgi|asp|js)(\.|$)/i', $file->filename)) {
1575+
if (preg_match('/\.(' . FILE_INSECURE_EXTENSIONS . ')(\.|$)/i', $file->filename)) {
15701576
// If the file will be rejected anyway due to a disallowed extension, it
15711577
// should not be renamed; rather, we'll let file_validate_extensions()
15721578
// reject it below.
@@ -1758,7 +1764,7 @@ function file_validate(stdClass &$file, $validators = array()) {
17581764
// malicious extension. Contributed and custom code that calls this method
17591765
// needs to take similar steps if they need to permit files with malicious
17601766
// extensions to be uploaded.
1761-
if (empty($errors) && !variable_get('allow_insecure_uploads', 0) && preg_match('/\.(php|phar|pl|py|cgi|asp|js)(\.|$)/i', $file->filename)) {
1767+
if (empty($errors) && !variable_get('allow_insecure_uploads', 0) && preg_match('/\.(' . FILE_INSECURE_EXTENSIONS . ')(\.|$)/i', $file->filename)) {
17621768
$errors[] = t('For security reasons, your upload has been rejected.');
17631769
}
17641770

includes/form.inc

+50-23
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,10 @@ function form_clear_error() {
16821682
}
16831683

16841684
/**
1685-
* Returns an associative array of all errors.
1685+
* Returns an associative array of all errors if any.
1686+
*
1687+
* @return array|null
1688+
* The form errors if any, NULL otherwise.
16861689
*/
16871690
function form_get_errors() {
16881691
$form = form_set_error();
@@ -2307,8 +2310,8 @@ function form_state_values_clean(&$form_state) {
23072310
* A keyed array containing the current state of the form.
23082311
*
23092312
* @return
2310-
* The data that will appear in the $form_state['values'] collection
2311-
* for this element. Return nothing to use the default.
2313+
* The data that will appear in $form_state['values'] for this element, or
2314+
* nothing to use the default.
23122315
*/
23132316
function form_type_image_button_value($form, $input, $form_state) {
23142317
if ($input !== FALSE) {
@@ -2353,8 +2356,8 @@ function form_type_image_button_value($form, $input, $form_state) {
23532356
* the element's default value should be returned.
23542357
*
23552358
* @return
2356-
* The data that will appear in the $element_state['values'] collection
2357-
* for this element. Return nothing to use the default.
2359+
* The data that will appear in $form_state['values'] for this element, or
2360+
* nothing to use the default.
23582361
*/
23592362
function form_type_checkbox_value($element, $input = FALSE) {
23602363
if ($input === FALSE) {
@@ -2394,8 +2397,8 @@ function form_type_checkbox_value($element, $input = FALSE) {
23942397
* the element's default value should be returned.
23952398
*
23962399
* @return
2397-
* The data that will appear in the $element_state['values'] collection
2398-
* for this element. Return nothing to use the default.
2400+
* The data that will appear in $form_state['values'] for this element, or
2401+
* nothing to use the default.
23992402
*/
24002403
function form_type_checkboxes_value($element, $input = FALSE) {
24012404
if ($input === FALSE) {
@@ -2435,8 +2438,8 @@ function form_type_checkboxes_value($element, $input = FALSE) {
24352438
* the element's default value should be returned.
24362439
*
24372440
* @return
2438-
* The data that will appear in the $element_state['values'] collection
2439-
* for this element. Return nothing to use the default.
2441+
* The data that will appear in $form_state['values'] for this element, or
2442+
* nothing to use the default.
24402443
*/
24412444
function form_type_tableselect_value($element, $input = FALSE) {
24422445
// If $element['#multiple'] == FALSE, then radio buttons are displayed and
@@ -2471,8 +2474,8 @@ function form_type_tableselect_value($element, $input = FALSE) {
24712474
* element's default value is returned. Defaults to FALSE.
24722475
*
24732476
* @return
2474-
* The data that will appear in the $element_state['values'] collection for
2475-
* this element.
2477+
* The data that will appear in $form_state['values'] for this element, or
2478+
* nothing to use the default.
24762479
*/
24772480
function form_type_radios_value(&$element, $input = FALSE) {
24782481
if ($input !== FALSE) {
@@ -2510,8 +2513,8 @@ function form_type_radios_value(&$element, $input = FALSE) {
25102513
* the element's default value should be returned.
25112514
*
25122515
* @return
2513-
* The data that will appear in the $element_state['values'] collection
2514-
* for this element. Return nothing to use the default.
2516+
* The data that will appear in $form_state['values'] for this element, or
2517+
* nothing to use the default.
25152518
*/
25162519
function form_type_password_confirm_value($element, $input = FALSE) {
25172520
if ($input === FALSE) {
@@ -2541,8 +2544,8 @@ function form_type_password_confirm_value($element, $input = FALSE) {
25412544
* the element's default value should be returned.
25422545
*
25432546
* @return
2544-
* The data that will appear in the $element_state['values'] collection
2545-
* for this element. Return nothing to use the default.
2547+
* The data that will appear in $form_state['values'] for this element, or
2548+
* nothing to use the default.
25462549
*/
25472550
function form_type_select_value($element, $input = FALSE) {
25482551
if ($input !== FALSE) {
@@ -2578,12 +2581,12 @@ function form_type_select_value($element, $input = FALSE) {
25782581
* @param array $element
25792582
* The form element whose value is being populated.
25802583
* @param mixed $input
2581-
* The incoming input to populate the form element. If this is FALSE,
2582-
* the element's default value should be returned.
2584+
* The incoming input to populate the form element. If this is FALSE, the
2585+
* element's default value should be returned.
25832586
*
25842587
* @return string
2585-
* The data that will appear in the $element_state['values'] collection
2586-
* for this element. Return nothing to use the default.
2588+
* The data that will appear in $form_state['values'] for this element, or
2589+
* nothing to use the default.
25872590
*/
25882591
function form_type_textarea_value($element, $input = FALSE) {
25892592
if ($input !== FALSE && $input !== NULL) {
@@ -2603,8 +2606,8 @@ function form_type_textarea_value($element, $input = FALSE) {
26032606
* the element's default value should be returned.
26042607
*
26052608
* @return
2606-
* The data that will appear in the $element_state['values'] collection
2607-
* for this element. Return nothing to use the default.
2609+
* The data that will appear in $form_state['values'] for this element, or
2610+
* nothing to use the default.
26082611
*/
26092612
function form_type_textfield_value($element, $input = FALSE) {
26102613
if ($input !== FALSE && $input !== NULL) {
@@ -2627,8 +2630,8 @@ function form_type_textfield_value($element, $input = FALSE) {
26272630
* the element's default value should be returned.
26282631
*
26292632
* @return
2630-
* The data that will appear in the $element_state['values'] collection
2631-
* for this element. Return nothing to use the default.
2633+
* The data that will appear in $form_state['values'] for this element, or
2634+
* nothing to use the default.
26322635
*/
26332636
function form_type_token_value($element, $input = FALSE) {
26342637
if ($input !== FALSE) {
@@ -3377,6 +3380,30 @@ function form_process_actions($element, &$form_state) {
33773380
return $element;
33783381
}
33793382

3383+
/**
3384+
* Processes a form button element.
3385+
*
3386+
* @param $element
3387+
* An associative array containing the properties and children of the
3388+
* form button.
3389+
* @param $form_state
3390+
* The $form_state array for the form this element belongs to.
3391+
*
3392+
* @return
3393+
* The processed element.
3394+
*/
3395+
function form_process_button($element, &$form_state) {
3396+
// We normally want to add drupal.form-single-submit so that the double submit
3397+
// protection can be added to the site, however, with the addition of
3398+
// javascript_always_use_jquery, this would make most pages with a login
3399+
// block or a search form have jquery always added, changing what people who
3400+
// set the javascript_always_use_jquery variable to FALSE would have expected.
3401+
if (variable_get('javascript_always_use_jquery', TRUE) && variable_get('javascript_use_double_submit_protection', TRUE)) {
3402+
$element['#attached']['library'][] = array('system', 'drupal.form-single-submit');
3403+
}
3404+
return $element;
3405+
}
3406+
33803407
/**
33813408
* Processes a container element.
33823409
*

includes/locale.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ function _locale_import_one_string($op, $value = NULL, $mode = NULL, $lang = NUL
10931093
*
10941094
* @param $report
10951095
* Report array summarizing the number of changes done in the form:
1096-
* array(inserts, updates, deletes).
1096+
* array(additions, deletes, skips, updates).
10971097
* @param $langcode
10981098
* Language code to import string into.
10991099
* @param $context

0 commit comments

Comments
 (0)