security update for contrib modules

This commit is contained in:
2019-04-23 16:27:46 +02:00
parent 3c1b4f164e
commit 868629cbb2
729 changed files with 41254 additions and 20866 deletions
@@ -7,7 +7,7 @@
* Adds the required Javascript to all your Drupal pages to allow tracking by
* the Google Analytics statistics package.
*
* @author: Alexander Hass <http://drupal.org/user/85918>
* @author: Alexander Hass <https://drupal.org/user/85918>
*/
/**
@@ -17,7 +17,7 @@ define('GOOGLEANALYTICS_TRACKFILES_EXTENSIONS', '7z|aac|arc|arj|asf|asx|avi|bin|
/**
* Define default path exclusion list to remove tracking from admin pages,
* see http://drupal.org/node/34970 for more information.
* see https://drupal.org/node/34970 for more information.
*/
define('GOOGLEANALYTICS_PAGES', "admin\nadmin/*\nbatch\nnode/add*\nnode/*/*\nuser/*/*");
@@ -36,7 +36,7 @@ function googleanalytics_api() {
function googleanalytics_help($path, $arg) {
switch ($path) {
case 'admin/config/system/googleanalytics':
return t('<a href="@ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'http://www.google.com/analytics/'));
return t('<a href="@ga_url">Google Analytics</a> is a free (registration required) website traffic and marketing effectiveness service.', array('@ga_url' => 'https://marketingplatform.google.com/about/analytics/'));
}
}
@@ -69,6 +69,11 @@ function googleanalytics_permission() {
'description' => t('Enter PHP code in the field for tracking visibility settings.'),
'restrict access' => TRUE,
),
'add JS snippets for google analytics' => array(
'title' => t('Add JavaScript snippets'),
'description' => 'Enter JavaScript code snippets for advanced Google Analytics functionality.',
'restrict access' => TRUE,
),
);
}
@@ -93,7 +98,7 @@ function googleanalytics_menu() {
* Implements hook_page_alter() to insert JavaScript to the appropriate scope/region of the page.
*/
function googleanalytics_page_alter(&$page) {
global $user;
global $base_path, $user;
$id = variable_get('googleanalytics_account', '');
@@ -125,8 +130,11 @@ function googleanalytics_page_alter(&$page) {
$link_settings['trackDownload'] = $track_download;
$link_settings['trackDownloadExtensions'] = $trackfiles_extensions;
}
if (module_exists('colorbox') && ($track_colorbox = variable_get('googleanalytics_trackcolorbox', 1))) {
$link_settings['trackColorbox'] = $track_colorbox;
}
if ($track_domain_mode = variable_get('googleanalytics_domain_mode', 0)) {
$link_settings['trackDomainMode'] = $track_domain_mode;
$link_settings['trackDomainMode'] = (int) $track_domain_mode;
}
if ($track_cross_domains = variable_get('googleanalytics_cross_domains', '')) {
$link_settings['trackCrossDomains'] = preg_split('/(\r\n?|\n)/', $track_cross_domains);
@@ -193,11 +201,23 @@ function googleanalytics_page_alter(&$page) {
// Track access denied (403) and file not found (404) pages.
if ($status == '403 Forbidden') {
// See http://www.google.com/support/analytics/bin/answer.py?answer=86927
$url_custom = '"/403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
// See https://www.google.com/support/analytics/bin/answer.py?answer=86927
$url_custom = '"' . $base_path . '403.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
elseif ($status == '404 Not Found') {
$url_custom = '"/404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
$url_custom = '"' . $base_path . '404.html?page=" + document.location.pathname + document.location.search + "&from=" + document.referrer';
}
// #2693595: User has entered an invalid login and clicked on forgot
// password link. This link contains the username or email address and may
// get send to Google if we do not override it. Override only if 'name'
// query param exists. Last custom url condition, this need to win.
//
// URLs to protect are:
// - user/password?name=username
// - user/password?name=foo@example.com
if (arg(0) == 'user' && arg(1) == 'password' && array_key_exists('name', drupal_get_query_parameters())) {
$url_custom = '"' . $base_path . 'user/password"';
}
// Add custom dimensions and metrics.
@@ -248,11 +268,10 @@ function googleanalytics_page_alter(&$page) {
$script .= '})(window,document,"script",';
// Which version of the tracking library should be used?
$library_tracker_url = '//www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
$library_cache_url = 'http:' . $library_tracker_url;
$library_tracker_url = 'https://www.google-analytics.com/' . ($debug ? 'analytics_debug.js' : 'analytics.js');
// Should a local cached copy of analytics.js be used?
if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_cache_url)) {
if (variable_get('googleanalytics_cache', 0) && $url = _googleanalytics_cache($library_tracker_url)) {
// A dummy query-string is added to filenames, to gain control over
// browser-caching. The string changes on every update or full cache
// flush, forcing browsers to load a new copy of the files, as the
@@ -294,10 +313,7 @@ function googleanalytics_page_alter(&$page) {
// Track logged in users across all devices.
if (variable_get('googleanalytics_trackuserid', 0) && user_is_logged_in()) {
// The USER_ID value should be a unique, persistent, and non-personally
// identifiable string identifier that represents a user or signed-in
// account across devices.
$create_only_fields['userId'] = drupal_hmac_base64($user->uid, drupal_get_private_key() . drupal_get_hash_salt());
$create_only_fields['userId'] = google_analytics_user_id_hash($user->uid);
}
// Create a tracker.
@@ -352,13 +368,30 @@ function googleanalytics_page_alter(&$page) {
// Custom tracking. Prepend before all other JavaScript.
// @TODO: https://support.google.com/adsense/answer/98142
// sounds like it could be appended to $script.
drupal_add_js($googleanalytics_adsense_script, array('type' => 'inline', 'group' => JS_LIBRARY-1));
drupal_add_js($googleanalytics_adsense_script, array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
}
drupal_add_js($script, array('scope' => 'header', 'type' => 'inline'));
drupal_add_js($script, array('scope' => 'header', 'type' => 'inline', 'requires_jquery' => FALSE));
}
}
/**
* Generate user id hash to implement USER_ID.
*
* The USER_ID value should be a unique, persistent, and non-personally
* identifiable string identifier that represents a user or signed-in
* account across devices.
*
* @param int $uid
* User id.
*
* @return string
* User id hash.
*/
function google_analytics_user_id_hash($uid) {
return drupal_hmac_base64($uid, drupal_get_private_key() . drupal_get_hash_salt());
}
/**
* Implements hook_field_extra_fields().
*/
@@ -440,7 +473,7 @@ function googleanalytics_user_presave(&$edit, $account, $category) {
function googleanalytics_cron() {
// Regenerate the tracking code file every day.
if (REQUEST_TIME - variable_get('googleanalytics_last_cache', 0) >= 86400 && variable_get('googleanalytics_cache', 0)) {
_googleanalytics_cache('http://www.google-analytics.com/analytics.js', TRUE);
_googleanalytics_cache('https://www.google-analytics.com/analytics.js', TRUE);
variable_set('googleanalytics_last_cache', REQUEST_TIME);
}
}
@@ -456,14 +489,14 @@ function googleanalytics_preprocess_search_results(&$variables) {
// found. But the pager item mumber can tell the number of search results.
global $pager_total_items;
drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1));
drupal_add_js('window.googleanalytics_search_results = ' . intval($pager_total_items[0]) . ';', array('type' => 'inline', 'group' => JS_LIBRARY-1, 'requires_jquery' => FALSE));
}
}
/**
* Helper function for grabbing search keys. Function is missing in D7.
*
* http://api.drupal.org/api/function/search_get_keys/6
* https://api.drupal.org/api/function/search_get_keys/6
*/
function googleanalytics_search_get_keys() {
static $return;
@@ -504,6 +537,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
if ($data_hash_local != $data_hash_remote && file_prepare_directory($path)) {
// Save updated tracking code file to disk.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
// Based on Drupal Core drupal_build_css_cache().
if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
}
watchdog('googleanalytics', 'Locally cached tracking code file has been updated.', array(), WATCHDOG_INFO);
// Change query-strings on css/js files to enforce reload for all users.
@@ -516,6 +553,10 @@ function _googleanalytics_cache($location, $synchronize = FALSE) {
// There is no need to flush JS here as core refreshes JS caches
// automatically, if new files are added.
file_unmanaged_save_data($result->data, $file_destination, FILE_EXISTS_REPLACE);
// Based on Drupal Core drupal_build_css_cache().
if (variable_get('css_gzip_compression', TRUE) && variable_get('clean_url', 0) && extension_loaded('zlib')) {
file_unmanaged_save_data(gzencode($result->data, 9, FORCE_GZIP), $file_destination . '.gz', FILE_EXISTS_REPLACE);
}
watchdog('googleanalytics', 'Locally cached tracking code file has been saved.', array(), WATCHDOG_INFO);
// Return the local JS file path.