security update link,module_filters,search_api_solr,ubercart,views

This commit is contained in:
2019-04-24 16:39:12 +02:00
parent 0aea7a0db1
commit 514f3bd89e
497 changed files with 9038 additions and 3662 deletions

View File

@@ -1,113 +0,0 @@
<?php
/**
* @file
* Contains functions handling views integration.
*/
/**
* Implementation of hook_views_handlers().
*/
/*function link_views_handlers() {
return array(
'info' => array(
'path' => drupal_get_path('module', 'link') .'/views',
),
'handlers' => array(
'link_views_handler_argument_target' => array(
'parent' => 'views_handler_argument',
),
'link_views_handler_filter_protocol' => array(
'parent' => 'views_handler_filter_string',
),
),
);
}*/
/**
* Return CCK Views data for the link_field_settings($op == 'views data').
*
* @TODO: Is there some way to tell views I have formatters for it?
*/
/*function link_views_content_field_data($field) {
// Build the automatic views data provided for us by CCK.
// This creates all the information necessary for the "url" field.
$data = content_views_field_views_data($field);
$db_info = content_database_info($field);
$table_alias = content_views_tablename($field);
$field_types = _content_field_types();
// Tweak the automatic views data for the link "url" field.
// Set the filter title to "@label URL"
$data[$table_alias][$field['field_name'] .'_url']['filter']['title'] = t('@label URL', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']);
// Remove the argument handling for URLs.
unset($data[$table_alias][$field['field_name'] .'_url']['argument']);
// Build out additional views data for the link "title" field.
$data[$table_alias][$field['field_name'] .'_title'] = array(
'group' => t('Content'),
'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
'argument' => array(
'field' => $db_info['columns']['title']['column'],
'tablename' => $db_info['table'],
'handler' => 'content_handler_argument_string',
'click sortable' => TRUE,
'name field' => '', // TODO, mimic content.views.inc :)
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
),
'filter' => array(
'field' => $db_info['columns']['title']['column'],
'title' => t('@label title', array('@label' => t($field_types[$field['type']]['label']))),
'tablename' => $db_info['table'],
'handler' => 'content_handler_filter_string',
'additional fields' => array(),
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
),
'sort' => array(
'field' => $db_info['columns']['title']['column'],
'tablename' => $db_info['table'],
'handler' => 'content_handler_sort',
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
),
);
// Build out additional Views filter for the link "protocol" pseudo field.
// TODO: Add a protocol argument.
$data[$table_alias][$field['field_name'] .'_protocol'] = array(
'group' => t('Content'),
'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
'filter' => array(
'field' => $db_info['columns']['url']['column'],
'title' => t('@label protocol', array('@label' => t($field_types[$field['type']]['label']))),
'tablename' => $db_info['table'],
'handler' => 'link_views_handler_filter_protocol',
'additional fields' => array(),
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
),
);
// Build out additional Views argument for the link "target" pseudo field.
// TODO: Add a target filter.
$data[$table_alias][$field['field_name'] .'_target'] = array(
'group' => t('Content'),
'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
'help' => $data[$table_alias][$field['field_name'] .'_url']['help'],
'argument' => array(
'field' => $db_info['columns']['attributes']['column'],
'title' => t('@label target', array('@label' => t($field_types[$field['type']]['label']))) .': '. t($field['widget']['label']) .' ('. $field['field_name'] .')',
'tablename' => $db_info['table'],
'handler' => 'link_views_handler_argument_target',
'additional fields' => array(),
'content_field_name' => $field['field_name'],
'allow_empty' => TRUE,
),
);
return $data;
}*/

View File

@@ -7,20 +7,26 @@
/**
* Argument handler to filter results by target.
*
* @codingStandardsIgnoreStart
*/
class link_views_handler_argument_target extends views_handler_argument {
/**
* Provide defaults for the argument when a new one is created.
*/
function options(&$options) {
parent::options($options);
}
function option_definition() {
$options = parent::option_definition();
return $options;
}
/**
* Provide a default options form for the argument.
*
* @codingStandardsIgnoreStart
*/
function options_form(&$form, &$form_state) {
public function options_form(&$form, &$form_state) {
// @codingStandardsIgnoreEnd
$defaults = $this->default_actions();
$form['title'] = array(
@@ -52,7 +58,7 @@ class link_views_handler_argument_target extends views_handler_argument {
$form['wildcard'] = array(
'#prefix' => '<div class="views-right-50">',
// prefix and no suffix means these two items will be grouped together.
// Prefix and no suffix means these two items will be grouped together.
'#type' => 'textfield',
'#title' => t('Wildcard'),
'#size' => 20,
@@ -125,8 +131,8 @@ class link_views_handler_argument_target extends views_handler_argument {
asort($validate_types);
$form['validate_type']['#options'] = $validate_types;
// Show this gadget if *anything* but 'none' is selected
// Show this gadget if *anything* but 'none' is selected.
$form['validate_fail'] = array(
'#type' => 'select',
'#title' => t('Action to take if argument does not validate'),
@@ -140,10 +146,11 @@ class link_views_handler_argument_target extends views_handler_argument {
*
* The argument sent may be found at $this->argument.
*/
function query($group_by = FALSE) {
public function query($group_by = FALSE) {
$this->ensure_my_table();
// Because attributes are stored serialized, our only option is to also
// serialize the data we're searching for and use LIKE to find similar data.
$this->query->add_where(0, $this->table_alias . ' . ' . $this->real_field . " LIKE '%%%s%'", serialize(array('target' => $this->argument)));
}
}

View File

@@ -7,22 +7,29 @@
/**
* Filter handler for limiting a view to URLs of a certain protocol.
*
* @codingStandardsIgnoreStart
*/
class link_views_handler_filter_protocol extends views_handler_filter_string {
/**
* Set defaults for the filter options.
*/
function options(&$options) {
parent::options($options);
public function option_definition() {
// @codingStandardsIgnoreEnd
$options = parent::option_definition();
$options['operator'] = 'OR';
$options['value'] = 'http';
$options['case'] = 0;
return $options;
}
/**
* Define the operators supported for protocols.
*/
function operators() {
public function operators() {
$operators = array(
'OR' => array(
'title' => t('Is one of'),
@@ -35,7 +42,13 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
return $operators;
}
function options_form(&$form, &$form_state) {
/**
* Options form.
*
* @codingStandardsIgnoreStart
*/
public function options_form(&$form, &$form_state) {
//@codingStandardsIgnoreEnd
parent::options_form($form, $form_state);
$form['case'] = array(
'#type' => 'value',
@@ -45,8 +58,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
/**
* Provide a select list to choose the desired protocols.
*
* @codingStandardsIgnoreStart
*/
function value_form(&$form, &$form_state) {
public function value_form(&$form, &$form_state) {
// @codingStandardsIgnoreEnd
// We have to make some choices when creating this as an exposed
// filter form. For example, if the operator is locked and thus
// not rendered, we can't render dependencies; instead we only
@@ -61,7 +77,19 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
'#type' => 'select',
'#title' => t('Protocol'),
'#default_value' => $this->value,
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'))),
'#options' => drupal_map_assoc(variable_get('filter_allowed_protocols', array(
'http',
'https',
'ftp',
'news',
'nntp',
'telnet',
'mailto',
'irc',
'ssh',
'sftp',
'webcal',
))),
'#multiple' => 1,
'#size' => 4,
'#description' => t('The protocols displayed here are those globally available. You may add more protocols by modifying the <em>filter_allowed_protocols</em> variable in your installation.'),
@@ -71,8 +99,11 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
/**
* Filter down the query to include only the selected protocols.
*
* @codingStandardsIgnoreStart
*/
function op_protocol($field, $upper) {
public function op_protocol($field, $upper) {
// @codingStandardsIgnoreEnd
$db_type = db_driver();
$protocols = $this->value;
@@ -82,20 +113,25 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
// Simple case, the URL begins with the specified protocol.
$condition = $field . ' LIKE \'' . $protocol . '%\'';
// More complex case, no protocol specified but is automatically cleaned up
// by link_cleanup_url(). RegEx is required for this search operation.
// More complex case, no protocol specified but is automatically cleaned
// up by link_cleanup_url(). RegEx is required for this search operation.
if ($protocol == 'http') {
$LINK_DOMAINS = _link_domains();
$link_domains = _link_domains();
if ($db_type == 'pgsql') {
// PostGreSQL code has NOT been tested. Please report any problems to the link issue queue.
// pgSQL requires all slashes to be double escaped in regular expressions.
// PostGreSQL code has NOT been tested. Please report any problems to
// the link issue queue.
// pgSQL requires all slashes to be double escaped in regular
// expressions.
// @codingStandardsIgnoreLine
// See http://www.postgresql.org/docs/8.1/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP
$condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
$condition .= ' OR ' . $field . ' ~* \'' . '^(([a-z0-9]([a-z0-9\\-_]*\\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
}
else {
// mySQL requires backslashes to be double (triple?) escaped within character classes.
// mySQL requires backslashes to be double (triple?) escaped within
// character classes.
// @codingStandardsIgnoreLine
// See http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_regexp
$condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $LINK_DOMAINS . '|[a-z][a-z]))' . '\'';
$condition .= ' OR ' . $field . ' REGEXP \'' . '^(([a-z0-9]([a-z0-9\\\-_]*\.)+)(' . $link_domains . '|[a-z][a-z]))' . '\'';
}
}
@@ -104,4 +140,5 @@ class link_views_handler_filter_protocol extends views_handler_filter_string {
$this->query->add_where($this->options['group'], implode(' ' . $this->operator . ' ', $where_conditions));
}
}