Loading google_analytics.module +4 −5 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; Loading Loading @@ -209,7 +208,7 @@ function google_analytics_page_attachments(array &$page) { $google_analytics_custom_var['value'] = \Drupal::token()->replace($google_analytics_custom_var['value'], $types, ['clear' => TRUE]); // Suppress empty values. if (!Unicode::strlen(trim($google_analytics_custom_var['value']))) { if (!mb_strlen(trim($google_analytics_custom_var['value']))) { continue; } Loading @@ -217,7 +216,7 @@ function google_analytics_page_attachments(array &$page) { // A metric has no length limitation. It's not documented if this // limit means 150 bytes after url encoding or before. // See https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs if ($google_analytics_custom_type == 'dimension' && Unicode::strlen($google_analytics_custom_var['value']) > 150) { if ($google_analytics_custom_type == 'dimension' && mb_strlen($google_analytics_custom_var['value']) > 150) { $google_analytics_custom_var['value'] = substr($google_analytics_custom_var['value'], 0, 150); } Loading Loading @@ -649,11 +648,11 @@ function _google_analytics_visibility_pages() { if (!empty($visibility_request_path_pages)) { // Convert path to lowercase. This allows comparison of the same path // with different case. Ex: /Page, /page, /PAGE. $pages = Unicode::strtolower($visibility_request_path_pages); $pages = mb_strtolower($visibility_request_path_pages); if ($visibility_request_path_mode < 2) { // Compare the lowercase path alias (if any) and internal path. $path = \Drupal::service('path.current')->getPath(); $path_alias = Unicode::strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($path)); $path_alias = mb_strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($path)); $page_match = \Drupal::service('path.matcher')->matchPath($path_alias, $pages) || (($path != $path_alias) && \Drupal::service('path.matcher')->matchPath($path, $pages)); // When $visibility_request_path_mode has a value of 0, the tracking // code is displayed on all pages except those listed in $pages. When Loading src/Form/GoogleAnalyticsAdminSettingsForm.php +6 −7 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Drupal\google_analytics\Form; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Form\ConfigFormBase; Loading Loading @@ -565,7 +564,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($form_state->getValue(['google_analytics_custom_dimension', 'indexes']) as $dimension) { $form_state->setValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value'], trim($dimension['value'])); // Remove empty values from the array. if (!Unicode::strlen($form_state->getValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value']))) { if (!mb_strlen($form_state->getValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value']))) { $form_state->unsetValue(['google_analytics_custom_dimension', 'indexes', $dimension['index']]); } } Loading @@ -574,7 +573,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($form_state->getValue(['google_analytics_custom_metric', 'indexes']) as $metric) { $form_state->setValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value'], trim($metric['value'])); // Remove empty values from the array. if (!Unicode::strlen($form_state->getValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value']))) { if (!mb_strlen($form_state->getValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value']))) { $form_state->unsetValue(['google_analytics_custom_metric', 'indexes', $metric['index']]); } } Loading Loading @@ -703,7 +702,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { public static function tokenElementValidate(&$element, FormStateInterface $form_state) { $value = isset($element['#value']) ? $element['#value'] : $element['#default_value']; if (!Unicode::strlen($value)) { if (!mb_strlen($value)) { // Empty value needs no further validation since the element should depend // on using the '#required' FAPI property. return $element; Loading Loading @@ -924,10 +923,10 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { * The error message if the specified value is invalid, NULL otherwise. */ protected static function validateCreateFieldValue($value) { if (!is_bool($value) && !Unicode::strlen($value)) { if (!is_bool($value) && !mb_strlen($value)) { return t('A create only field requires a value.'); } if (Unicode::strlen($value) > 255) { if (mb_strlen($value) > 255) { return t('The value of a create only field must be a string at most 255 characters long.'); } } Loading Loading @@ -972,7 +971,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($values as $name => $value) { // Convert data types. $match = Unicode::strtolower($value); $match = mb_strtolower($value); if ($match == 'true') { $value = TRUE; } Loading Loading
google_analytics.module +4 −5 Original line number Diff line number Diff line Loading @@ -12,7 +12,6 @@ use Drupal\Component\Serialization\Json; use Drupal\Component\Utility\Crypt; use Drupal\Component\Utility\Unicode; use Drupal\Core\Cache\Cache; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; Loading Loading @@ -209,7 +208,7 @@ function google_analytics_page_attachments(array &$page) { $google_analytics_custom_var['value'] = \Drupal::token()->replace($google_analytics_custom_var['value'], $types, ['clear' => TRUE]); // Suppress empty values. if (!Unicode::strlen(trim($google_analytics_custom_var['value']))) { if (!mb_strlen(trim($google_analytics_custom_var['value']))) { continue; } Loading @@ -217,7 +216,7 @@ function google_analytics_page_attachments(array &$page) { // A metric has no length limitation. It's not documented if this // limit means 150 bytes after url encoding or before. // See https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#customs if ($google_analytics_custom_type == 'dimension' && Unicode::strlen($google_analytics_custom_var['value']) > 150) { if ($google_analytics_custom_type == 'dimension' && mb_strlen($google_analytics_custom_var['value']) > 150) { $google_analytics_custom_var['value'] = substr($google_analytics_custom_var['value'], 0, 150); } Loading Loading @@ -649,11 +648,11 @@ function _google_analytics_visibility_pages() { if (!empty($visibility_request_path_pages)) { // Convert path to lowercase. This allows comparison of the same path // with different case. Ex: /Page, /page, /PAGE. $pages = Unicode::strtolower($visibility_request_path_pages); $pages = mb_strtolower($visibility_request_path_pages); if ($visibility_request_path_mode < 2) { // Compare the lowercase path alias (if any) and internal path. $path = \Drupal::service('path.current')->getPath(); $path_alias = Unicode::strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($path)); $path_alias = mb_strtolower(\Drupal::service('path.alias_manager')->getAliasByPath($path)); $page_match = \Drupal::service('path.matcher')->matchPath($path_alias, $pages) || (($path != $path_alias) && \Drupal::service('path.matcher')->matchPath($path, $pages)); // When $visibility_request_path_mode has a value of 0, the tracking // code is displayed on all pages except those listed in $pages. When Loading
src/Form/GoogleAnalyticsAdminSettingsForm.php +6 −7 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ namespace Drupal\google_analytics\Form; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandler; use Drupal\Core\Form\ConfigFormBase; Loading Loading @@ -565,7 +564,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($form_state->getValue(['google_analytics_custom_dimension', 'indexes']) as $dimension) { $form_state->setValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value'], trim($dimension['value'])); // Remove empty values from the array. if (!Unicode::strlen($form_state->getValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value']))) { if (!mb_strlen($form_state->getValue(['google_analytics_custom_dimension', 'indexes', $dimension['index'], 'value']))) { $form_state->unsetValue(['google_analytics_custom_dimension', 'indexes', $dimension['index']]); } } Loading @@ -574,7 +573,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($form_state->getValue(['google_analytics_custom_metric', 'indexes']) as $metric) { $form_state->setValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value'], trim($metric['value'])); // Remove empty values from the array. if (!Unicode::strlen($form_state->getValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value']))) { if (!mb_strlen($form_state->getValue(['google_analytics_custom_metric', 'indexes', $metric['index'], 'value']))) { $form_state->unsetValue(['google_analytics_custom_metric', 'indexes', $metric['index']]); } } Loading Loading @@ -703,7 +702,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { public static function tokenElementValidate(&$element, FormStateInterface $form_state) { $value = isset($element['#value']) ? $element['#value'] : $element['#default_value']; if (!Unicode::strlen($value)) { if (!mb_strlen($value)) { // Empty value needs no further validation since the element should depend // on using the '#required' FAPI property. return $element; Loading Loading @@ -924,10 +923,10 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { * The error message if the specified value is invalid, NULL otherwise. */ protected static function validateCreateFieldValue($value) { if (!is_bool($value) && !Unicode::strlen($value)) { if (!is_bool($value) && !mb_strlen($value)) { return t('A create only field requires a value.'); } if (Unicode::strlen($value) > 255) { if (mb_strlen($value) > 255) { return t('The value of a create only field must be a string at most 255 characters long.'); } } Loading Loading @@ -972,7 +971,7 @@ class GoogleAnalyticsAdminSettingsForm extends ConfigFormBase { foreach ($values as $name => $value) { // Convert data types. $match = Unicode::strtolower($value); $match = mb_strtolower($value); if ($match == 'true') { $value = TRUE; } Loading