contrib modules security updates

This commit is contained in:
Bachir Soussi Chiadmi
2016-10-13 12:10:40 +02:00
parent ffd758abc9
commit 747127f643
732 changed files with 67976 additions and 23207 deletions

View File

@@ -10,7 +10,7 @@
*/
function jquery_update_help($path, $arg) {
switch ($path) {
// Help for another path in the block module
// Help for another path in the block module.
case 'admin/config/development/jquery_update':
return '<p>' . t('Configure how <a href="@jquery">jQuery</a> behaves on the site. Select which jQuery version, the compression level and whether or not to use a CDN.', array(
'@jquery' => 'http://jquery.com',
@@ -35,6 +35,17 @@ function jquery_update_library() {
'css' => array(
$path . '/qunit.css' => array(),
),
'version' => '1.11.0',
);
$libraries['jquery_update.ajax.fix'] = array(
'title' => 'jQuery Update Version Fix',
'js' => array(
drupal_get_path('module', 'jquery_update') . '/js/jquery_update.js' => array(
'group' => JS_LIBRARY,
'weight' => 3,
),
),
'version' => '0.0.1',
);
$libraries['jquery.metadata'] = array(
'title' => 'QUnit',
@@ -61,40 +72,77 @@ function jquery_update_library() {
}
/**
* Implementation of hook_library_alter().
* Implements hook_library_alter().
*/
function jquery_update_library_alter(&$javascript, $module) {
$path = drupal_get_path('module', 'jquery_update');
$version = variable_get('jquery_update_jquery_version', '1.10');
// We are updating just the system module. For all other cases we return.
if ($module != 'system') {
return;
// Modified System Library.
if ($module === 'system') {
// Make sure we inject either the minified or uncompressed version as desired.
$min = variable_get('jquery_update_compression_type', 'min') == 'none' ? '' : '.min';
$cdn = variable_get('jquery_update_jquery_cdn', 'none');
// Replace jQuery with the alternative version.
$admin_version = variable_get('jquery_update_jquery_admin_version', '');
if (!empty($admin_version) && path_is_admin(current_path())) {
if (version_compare($version, $admin_version, '!=')) {
$version = $admin_version;
}
}
// If the ajax version is set then that one always win.
if (!empty($_POST['ajax_page_state']['jquery_version'])) {
$ajax_version = $_POST['ajax_page_state']['jquery_version'];
if (in_array($ajax_version, array('default', '1.5', '1.6', '1.7', '1.8', '1.9', '1.10'))) {
$version = $ajax_version;
}
}
// Always add a new jquery_version array to ajaxPageState.
// This is what we used to determine which version to use
// for any ajax callback.
$javascript['drupal.ajax']['js'][] = array(
'data' => array('ajaxPageState' => array('jquery_version' => $version)),
'type' => 'setting',
);
$javascript['drupal.ajax']['dependencies'][] = array('jquery_update', 'jquery_update.ajax.fix');
// Don't replace anything if Drupal provided jQuery should be used
if ('default' == $version) {
return;
}
jquery_update_jquery_replace($javascript, $cdn, $path, $min, $version);
// Replace jQuery UI with CDN or local files. If from a CDN include all of
// jQuery UI.
if (version_compare($version, '1.6', '>=')) {
jquery_update_jqueryui_replace($javascript, $cdn, $path, $min);
}
// Replace the jQuery Cookie plugin.
$javascript['cookie']['js']['misc/jquery.cookie.js']['data'] = $path . '/replace/ui/external/jquery.cookie.js';
// Noting the version based on git commit as no version number is available.
$javascript['cookie']['version'] = '67fb34f6a866c40d0570';
// Replace jQuery Form plugin.
$javascript['jquery.form']['js']['misc/jquery.form.js']['data'] = $path . '/replace/misc/jquery.form' . $min . '.js';
$javascript['jquery.form']['version'] = '2.69';
// Replace files for Jquery 1.9 and up
if (version_compare($version, '1.9', '>=')) {
$javascript['jquery.bbq']['js']['misc/jquery.ba-bbq.js']['data'] = $path . '/replace/misc/1.9/jquery.ba-bbq' . $min . '.js';
}
}
$path = drupal_get_path('module', 'jquery_update');
// Make sure we inject either the minified or uncompressed version as desired.
$min = variable_get('jquery_update_compression_type', 'min') == 'none' ? '' : '.min';
$cdn = variable_get('jquery_update_jquery_cdn', 'none');
// Replace jQuery with the latest version.
$version = variable_get('jquery_update_jquery_version', '1.5');
jquery_update_jquery_replace($javascript, $cdn, $path, $min, $version);
// Replace jQuery UI with CDN or local files. If from a CDN include all of jQuery UI.
jquery_update_jqueryui_replace($javascript, $cdn, $path, $min);
// Replace the jQuery Cookie plugin.
$javascript['cookie']['js']['misc/jquery.cookie.js']['data'] = $path . '/replace/ui/external/jquery.cookie.js';
// Noting the version based on git commit as no version number is available.
$javascript['cookie']['version'] = '67fb34f6a866c40d0570';
// Replace jQuery Form plugin.
$javascript['jquery.form']['js']['misc/jquery.form.js']['data'] = $path . '/replace/misc/jquery.form' . $min . '.js';
$javascript['jquery.form']['version'] = '2.69';
// Replace files for jQuery 1.7 and up
if (version_compare($version, '1.7', '>=')) {
$javascript['drupal.states']['js']['misc/states.js']['data'] = $path . '/replace/misc/1.7/states.js';
if ($module == 'overlay') {
if (version_compare($version, '1.9', '>=')) {
$javascript['parent']['js']['modules/overlay/overlay-parent.js']['data'] = $path . '/replace/misc/1.9/overlay-parent.js';
}
}
}
@@ -114,20 +162,46 @@ function jquery_update_menu() {
}
/**
* Implementation of hook_form_FORM_ID().
* Admin settings menu callback.
*
* @see jquery_update_menu()
*/
function jquery_update_settings_form() {
$form['jquery_update_jquery_version'] = array(
$form['version_options'] = array(
'#type' => 'fieldset',
'#title' => t('Version options'),
);
$form['version_options']['jquery_update_jquery_version'] = array(
'#type' => 'select',
'#title' => t('jQuery Version'),
'#title' => t('Default jQuery Version'),
'#options' => array(
'default' => t('Default (provided by Drupal)'),
'1.5' => '1.5',
'1.7' => '1.7',
'1.8' => '1.8',
'1.9' => '1.9',
'1.10' => '1.10',
),
'#default_value' => variable_get('jquery_update_jquery_version', '1.5'),
'#description' => t('Select which jQuery version branch to use.'),
'#default_value' => variable_get('jquery_update_jquery_version', '1.10'),
'#description' => t('Select which jQuery version to use by default.'),
);
$form['version_options']['jquery_update_jquery_admin_version'] = array(
'#type' => 'select',
'#title' => t('Alternate jQuery version for administrative pages'),
'#options' => array(
'' => t('Default jQuery Version'),
'default' => t('Default (provided by Drupal)'),
'1.5' => '1.5',
'1.7' => '1.7',
'1.8' => '1.8',
'1.10' => '1.10',
),
'#default_value' => variable_get('jquery_update_jquery_admin_version', ''),
'#description' => t('Optionally select a different version of jQuery to use on administrative pages.'),
);
$form['jquery_update_compression_type'] = array(
'#type' => 'radios',
'#title' => t('jQuery compression level'),
@@ -135,6 +209,12 @@ function jquery_update_settings_form() {
'min' => t('Production (minified)'),
'none' => t('Development (uncompressed)'),
),
// Do not show this field if jQuery version is default
'#states' => array(
'invisible' => array(
':input[name=jquery_update_jquery_version]' => array('value' => "default"),
),
),
'#default_value' => variable_get('jquery_update_compression_type', 'min'),
);
$form['jquery_update_jquery_cdn'] = array(
@@ -146,6 +226,12 @@ function jquery_update_settings_form() {
'microsoft' => t('Microsoft'),
'jquery' => t('jQuery'),
),
// Do not show this field if jQuery version is default
'#states' => array(
'invisible' => array(
':input[name=jquery_update_jquery_version]' => array('value' => "default"),
),
),
'#default_value' => variable_get('jquery_update_jquery_cdn', 'none'),
'#description' => t('Use jQuery and jQuery UI from a CDN. If the CDN is not available the local version of jQuery and jQuery UI will be used.'),
);
@@ -163,45 +249,64 @@ function jquery_update_settings_form() {
* - none
* - google
* - microsoft
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified
* version.
* @param string $version
* The version of jQuery to use.
*/
function jquery_update_jquery_replace(&$javascript, $cdn, $path, $min, $version) {
// Make sure to use the latest version in given branch.
$trueversion = NULL;
switch ($version) {
case '1.5':
$trueversion = '1.5.2';
break;
case '1.7':
$trueversion = '1.7.1';
$trueversion = '1.7.2';
break;
case '1.8':
$trueversion = '1.8.2';
$trueversion = '1.8.3';
break;
case '1.9':
$trueversion = '1.9.1';
break;
case '1.10':
$trueversion = '1.10.2';
break;
}
$javascript['jquery']['version'] = $trueversion;
// Check for CDN support.
switch($cdn) {
switch ($cdn) {
case 'google':
$javascript['jquery']['js']['misc/jquery.js']['data'] = 'https://ajax.googleapis.com/ajax/libs/jquery/'. $trueversion . '/jquery' . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['data'] = '//ajax.googleapis.com/ajax/libs/jquery/' . $trueversion . '/jquery' . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
jquery_update_jquery_backup($javascript, $path, $min, $version);
break;
case 'microsoft':
$javascript['jquery']['js']['misc/jquery.js']['data'] = 'http://ajax.aspnetcdn.com/ajax/jQuery/jquery-'. $trueversion . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['data'] = '//ajax.aspnetcdn.com/ajax/jQuery/jquery-' . $trueversion . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
jquery_update_jquery_backup($javascript, $path, $min, $version);
break;
case 'jquery':
$javascript['jquery']['js']['misc/jquery.js']['data'] = 'http://code.jquery.com/jquery-'. $trueversion . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['data'] = '//code.jquery.com/jquery-' . $trueversion . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['type'] = 'external';
jquery_update_jquery_backup($javascript, $path, $min, $version);
break;
case 'none':
default:
$javascript['jquery']['js']['misc/jquery.js']['data'] = $path . '/replace/jquery/'. $version . '/jquery' . $min . '.js';
$javascript['jquery']['js']['misc/jquery.js']['data'] = $path . '/replace/jquery/' . $version . '/jquery' . $min . '.js';
break;
}
}
@@ -214,13 +319,14 @@ function jquery_update_jquery_replace(&$javascript, $cdn, $path, $min, $version)
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified version.
* The '.min' to include in the file name if we are requesting a minified
* version.
* @param string $version
* The verison of jQuery to use.
*/
function jquery_update_jquery_backup(&$javascript, $path, $min, $version) {
$javascript['jquery']['js'][] = array(
'data' => 'window.jQuery || document.write("<script src=\'' . base_path() . $path . '/replace/jquery/'. $version . '/jquery' . $min . '.js\'>\x3C/script>")',
'data' => 'window.jQuery || document.write("<script src=\'' . base_path() . $path . '/replace/jquery/' . $version . '/jquery' . $min . '.js\'>\x3C/script>")',
'type' => 'inline',
'group' => JS_LIBRARY,
'weight' => -19.999999999,
@@ -237,13 +343,46 @@ function jquery_update_jquery_backup(&$javascript, $path, $min, $version) {
* - none
* - google
* - microsoft
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified
* version.
*/
function jquery_update_jqueryui_replace(&$javascript, $cdn, $path, $min) {
// Add new components
$javascript['ui.menu'] = array(
'title' => 'jQuery UI: Menu',
'website' => 'http://jqueryui.com/demos/menu/',
'version' => '1.10.2',
'js' => array('misc/ui/jquery.ui.menu.min.js' => array()),
'css' => array('misc/ui/jquery.ui.menu.css' => array()),
'dependencies' => array(array('system', 'ui.widget'), array('system', 'ui.position')),
);
$javascript['ui.spinner'] = array(
'title' => 'jQuery UI: Spinner',
'website' => 'http://jqueryui.com/demos/spinner/',
'version' => '1.10.2',
'js' => array('misc/ui/jquery.ui.spinner.min.js' => array()),
'css' => array('misc/ui/jquery.ui.spinner.css' => array()),
'dependencies' => array(array('system', 'ui.widget'), array('system', 'ui.button')),
);
$javascript['ui.tooltip'] = array(
'title' => 'jQuery UI: Spinner',
'website' => 'http://jqueryui.com/demos/tooltip/',
'version' => '1.10.2',
'js' => array('misc/ui/jquery.ui.tooltip.min.js' => array()),
'css' => array('misc/ui/jquery.ui.tooltip.css' => array()),
'dependencies' => array(array('system', 'ui.widget'), array('system', 'ui.position')),
);
// fix dependencies
$javascript['ui.autocomplete']['dependencies'][] = array('system', 'ui.menu');
// Replace all CSS files.
$names = drupal_map_assoc(array(
'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker',
'ui.dialog', 'ui.progressbar', 'ui.resizable', 'ui.selectable',
'ui.slider', 'ui.tabs',
'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker', 'ui.dialog',
'ui.progressbar', 'ui.resizable', 'ui.selectable', 'ui.slider', 'ui.tabs',
'ui.menu', 'ui.spinner', 'ui.tooltip',
));
$names['ui'] = 'ui.core';
$csspath = $path . '/replace/ui/themes/base/' . (($min == '.min') ? 'minified/' : '');
@@ -255,34 +394,63 @@ function jquery_update_jqueryui_replace(&$javascript, $cdn, $path, $min) {
// Replace jQuery UI's JavaScript, beginning by defining the mapping.
$names = drupal_map_assoc(array(
'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker',
'ui.dialog', 'ui.draggable', 'ui.droppable', 'ui.mouse', 'ui.position',
'ui.progressbar', 'ui.resizable', 'ui.selectable', 'ui.slider',
'ui.sortable', 'ui.tabs', 'ui.widget', 'effects.blind', 'effects.bounce',
'effects.clip', 'effects.drop', 'effects.explode', 'effects.fade',
'effects.fold', 'effects.highlight', 'effects.pulsate', 'effects.scale',
'effects.shake', 'effects.slide', 'effects.transfer',
'ui.accordion', 'ui.autocomplete', 'ui.button', 'ui.datepicker', 'ui.dialog', 'ui.draggable',
'ui.droppable', 'ui.mouse', 'ui.position', 'ui.progressbar', 'ui.resizable', 'ui.selectable',
'ui.slider', 'ui.sortable', 'ui.tabs', 'ui.widget', 'ui.spinner', 'ui.menu', 'ui.tooltip',
));
$names['ui'] = 'ui.core';
$names['effects'] = 'effects.core';
$names['effects'] = array('effects.core', 'ui.effect'); // map[library_hook] = array(core_fn, updated_fn)
$names = jquery_update_make_library_hook_to_file_name_segment_map_for_effects($names);
switch($cdn) {
switch ($cdn) {
case 'google':
$cdn = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/jquery-ui' . $min . '.js';
$cdn = '//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui' . $min . '.js';
jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
jquery_update_jqueryui_backup($javascript, $path, $min);
break;
case 'microsoft':
$cdn = 'http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.11/jquery-ui' . $min . '.js';
$cdn = '//ajax.aspnetcdn.com/ajax/jquery.ui/1.10.2/jquery-ui' . $min . '.js';
jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
jquery_update_jqueryui_backup($javascript, $path, $min);
break;
case 'jquery':
$cdn = '//code.jquery.com/ui/1.10.2/jquery-ui' . $min . '.js';
jquery_update_jqueryui_cdn($cdn, $javascript, $path, $min, $names);
jquery_update_jqueryui_backup($javascript, $path, $min);
break;
case 'none':
jquery_update_jqueryui_local($javascript, $path, $min, $names);
break;
}
}
/**
* Create a mapping from system.module library hooks to file name segments.
*
* @param array $map Optional. If given, append to it.
* @return array The keys are library hooks and the values are each arrays of
* 2 file name segments as values. The first file name segment can be used to
* reach Drupal core's jQuery UI effect files, and the second file name segment
* can be used to construct a path to the equivalent replacement
* jQuery UI effect file provided by jquery_update.module.
*/
function jquery_update_make_library_hook_to_file_name_segment_map_for_effects($map = array()) {
$effect_names = array(
'blind', 'bounce', 'clip', 'drop', 'explode', 'fade', 'fold',
'highlight', 'pulsate', 'scale', 'shake', 'slide', 'transfer',
);
foreach ($effect_names as $effect_name) {
$library_hook = 'effects.' . $effect_name;
$file_name_segment_core = $library_hook; // Yes, for the effect files, this is indeed identical.
$file_name_segment_updated = 'ui.effect-' . $effect_name;
$map[$library_hook] = array($file_name_segment_core, $file_name_segment_updated);
}
return $map;
}
/**
* Add the local fallback in case jQuery UI from the CDN is unavailable.
*
@@ -291,7 +459,8 @@ function jquery_update_jqueryui_replace(&$javascript, $cdn, $path, $min) {
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified version.
* The '.min' to include in the file name if we are requesting a minified
* version.
*/
function jquery_update_jqueryui_backup(&$javascript, $path, $min) {
$js_path = ($min == '.min') ? '/replace/ui/ui/minified/jquery-ui.min.js' : '/replace/ui/ui/jquery-ui.js';
@@ -306,13 +475,19 @@ function jquery_update_jqueryui_backup(&$javascript, $path, $min) {
/**
* Handle when jQuery UI is updated to the cdn version.
*
* @param string $cdn
* The name of the CDN option to use. Possible options are:
* - none
* - google
* - microsoft
* @param array $javascript
* The $libraries array as seen in hook_library_alter()
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified version.
* @param array $names
* The '.min' to include in the file name if we are requesting a minified
* version.
* * @param array $names
* An array mapping jquery ui parts to their file names.
*/
function jquery_update_jqueryui_cdn($cdn, &$javascript, $path, $min, $names) {
@@ -320,10 +495,11 @@ function jquery_update_jqueryui_cdn($cdn, &$javascript, $path, $min, $names) {
// Construct the jQuery UI path and replace the JavaScript.
$jspath = $path . '/replace/ui/ui/' . ($min == '.min' ? 'minified/' : '');
foreach ($names as $name => $file) {
$corefile = 'misc/ui/jquery.' . $file . '.min.js';
list($file_core, $file_updated) = is_array($file) ? $file : array($file, $file);
$corefile = 'misc/ui/jquery.' . $file_core . '.min.js';
// Remove the core files.
unset($javascript[$name]['js'][$corefile]);
$javascript[$name]['version'] = '1.8.11';
$javascript[$name]['version'] = '1.10.2';
}
// UI is used by all of UI. Add the js cdn here.
@@ -333,6 +509,13 @@ function jquery_update_jqueryui_cdn($cdn, &$javascript, $path, $min, $names) {
'group' => JS_LIBRARY,
'weight' => -11,
);
// The cdn puts jQuery UI core and the jQuery UI Effects library in the same
// file, but the latter can normally be used without the former. So we need
// to add a dependency to guarantee that code which uses the Effects library
// has the file loaded regardless of whether they are also using jQuery UI
// core.
$javascript['effects']['dependencies'][] = array('system', 'ui');
}
/**
@@ -343,7 +526,8 @@ function jquery_update_jqueryui_cdn($cdn, &$javascript, $path, $min, $names) {
* @param string $path
* The path to the module where replacements can be found.
* @param string $min
* The '.min' to include in the file name if we are requesting a minified version.
* The '.min' to include in the file name if we are requesting a minified
* version.
* @param array $names
* An array mapping jquery ui parts to their file names.
*/
@@ -352,8 +536,9 @@ function jquery_update_jqueryui_local(&$javascript, $path, $min, $names) {
// Construct the jQuery UI path and replace the JavaScript.
$jspath = $path . '/replace/ui/ui/' . ($min == '.min' ? 'minified/' : '');
foreach ($names as $name => $file) {
$corefile = 'misc/ui/jquery.' . $file . '.min.js';
$javascript[$name]['js'][$corefile]['data'] = $jspath . 'jquery.' . $file . $min . '.js';
$javascript[$name]['version'] = '1.8.11';
list($file_core, $file_updated) = is_array($file) ? $file : array($file, $file);
$corefile = 'misc/ui/jquery.' . $file_core . '.min.js';
$javascript[$name]['js'][$corefile]['data'] = $jspath . 'jquery.' . $file_updated . $min . '.js';
$javascript[$name]['version'] = '1.10.2';
}
}