security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -66,11 +66,43 @@ class ViewsHandlerFieldBooleanTest extends ViewsSqlTest {
$this->assertEqual('✖', $view->field['age']->advanced_render($view->result[0]));
$this->assertEqual('✔', $view->field['age']->advanced_render($view->result[1]));
// Set a custom output format.
// Set a custom output format programmatically.
$view->field['age']->formats['test'] = array(t('Test-True'), t('Test-False'));
$view->field['age']->options['type'] = 'test';
$this->assertEqual(t('Test-False'), $view->field['age']->advanced_render($view->result[0]));
$this->assertEqual(t('Test-True'), $view->field['age']->advanced_render($view->result[1]));
// Set a custom output format through the UI using plain-text inputs.
$view->field['age']->options['type'] = 'custom';
$values = array(
'false' => 'Nay',
'true' => 'Yay',
);
$view->field['age']->options['type_custom_false'] = $values['false'];
$view->field['age']->options['type_custom_true'] = $values['true'];
$this->assertEqual($values['false'], $view->field['age']->advanced_render($view->result[0]));
$this->assertEqual($values['true'], $view->field['age']->advanced_render($view->result[1]));
// Set a custom output format through the UI using valid HTML inputs.
$view->field['age']->options['type'] = 'custom';
$values = array(
'false' => '<div class="bar">Nay</div>',
'true' => '<div class="foo">Yay</div>',
);
$view->field['age']->options['type_custom_false'] = $values['false'];
$view->field['age']->options['type_custom_true'] = $values['true'];
$this->assertEqual($values['false'], $view->field['age']->advanced_render($view->result[0]));
$this->assertEqual($values['true'], $view->field['age']->advanced_render($view->result[1]));
// Set a custom output format through the UI using unsafe inputs.
$view->field['age']->options['type'] = 'custom';
$values = array(
'false' => '<script>alert("Nay");</script>',
'true' => '<script>alert("Yay");</script>',
);
$view->field['age']->options['type_custom_false'] = $values['false'];
$view->field['age']->options['type_custom_true'] = $values['true'];
$this->assertNotEqual($values['false'], $view->field['age']->advanced_render($view->result[0]));
$this->assertNotEqual($values['true'], $view->field['age']->advanced_render($view->result[1]));
}
}

View File

@@ -34,6 +34,8 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
'relationship' => 'none',
// c is iso 8601 date format @see http://php.net/manual/en/function.date.php
'custom_date_format' => 'c',
'second_date_format' => 'custom',
'second_date_format_custom' => 'c',
),
));
$time = gmmktime(0, 0, 0, 1, 1, 2000);
@@ -51,6 +53,8 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
'medium' => format_date($time, 'medium', '', $timezone),
'large' => format_date($time, 'large', '', $timezone),
'custom' => format_date($time, 'custom', 'c', $timezone),
'today time ago custom' => format_date($time, 'custom', 'c', $timezone),
'today time ago' => t('%time ago', array('%time' => format_interval(120, 2))),
);
$this->assertRenderedDatesEqual($view, $dates, $timezone);
}
@@ -67,6 +71,17 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
foreach ($map as $date_format => $expected_result) {
$check_result_number = 0;
// If it's "today time ago" format we have to check the 6th element.
if ($date_format == 'today time ago') {
$check_result_number = 5;
}
// Correct the date format.
if ($date_format == 'today time ago custom') {
$date_format = 'today time ago';
}
$view->field['created']->options['date_format'] = $date_format;
$t_args = array(
'%value' => $expected_result,
@@ -80,8 +95,23 @@ class ViewsHandlerFieldDateTest extends ViewsSqlTest {
else {
$message = t('Value %value in %format format matches.', $t_args);
}
$actual_result = $view->field['created']->advanced_render($view->result[0]);
$actual_result = $view->field['created']->advanced_render($view->result[$check_result_number]);
$this->assertEqual($expected_result, $actual_result, $message);
}
}
/**
* Appends dataSet() with a data row for "today time ago" format testing.
*/
protected function dataSet() {
$data = parent::dataSet();
$data[] = array(
'name' => 'David',
'age' => 25,
'job' => 'Singer',
'created' => REQUEST_TIME - 120,
);
return $data;
}
}

View File

@@ -0,0 +1,66 @@
<?php
/**
* @file
* Definition of ViewsHandlerFileExtensionTest.
*/
/**
* Tests the views_handler_field_file_extension handler.
*/
class ViewsHandlerFileExtensionTest extends ViewsSqlTest {
public static function getInfo() {
return array(
'name' => 'Field: File extension',
'description' => 'Test the views_handler_field_file_extension handler.',
'group' => 'Views Handlers',
);
}
function dataSet() {
$data = parent::dataSet();
$data[0]['name'] = 'file.png';
$data[1]['name'] = 'file.tar';
$data[2]['name'] = 'file.tar.gz';
$data[3]['name'] = 'file';
return $data;
}
function viewsData() {
$data = parent::viewsData();
$data['views_test']['name']['field']['handler'] = 'views_handler_field_file_extension';
$data['views_test']['name']['real field'] = 'name';
return $data;
}
/**
* Tests the 'extension_detect_tar' handler option.
*/
public function testFileExtensionTarOption() {
$view = $this->getBasicView();
$view->display['default']->handler->override_option('fields', array(
'name' => array(
'id' => 'name',
'table' => 'views_test',
'field' => 'name',
),
));
$this->executeView($view);
// Test without the tar option.
$this->assertEqual($view->field['name']->advanced_render($view->result[0]), 'png');
$this->assertEqual($view->field['name']->advanced_render($view->result[1]), 'tar');
$this->assertEqual($view->field['name']->advanced_render($view->result[2]), 'gz');
$this->assertEqual($view->field['name']->advanced_render($view->result[3]), '');
// Test with the tar option.
$view->field['name']->options['extension_detect_tar'] = TRUE;
$this->assertEqual($view->field['name']->advanced_render($view->result[0]), 'png');
$this->assertEqual($view->field['name']->advanced_render($view->result[1]), 'tar');
$this->assertEqual($view->field['name']->advanced_render($view->result[2]), 'tar.gz');
$this->assertEqual($view->field['name']->advanced_render($view->result[3]), '');
}
}

View File

@@ -0,0 +1,81 @@
<?php
/**
* @file
* Contains ViewsHandlerTest.
*/
/**
* Tests generic handler functionality.
*
* @see view
*/
class ViewsHandlerTest extends ViewsSqlTest {
public static function getInfo() {
return array(
'name' => 'Handlers',
'description' => 'Tests generic handler functionality.',
'group' => 'Views Handlers',
);
}
/**
* {@inheritdoc}
*/
protected function viewsData() {
$views_data = parent::viewsData();
$views_data['views']['test_access'] = array(
'title' => 'test access',
'help' => '',
'area' => array(
'handler' => 'views_test_area_access',
),
);
return $views_data;
}
/**
* Tests access for handlers using an area handler.
*/
public function testHandlerAccess() {
$view = $this->getBasicView();
// add a test area
$view->display['default']->handler->override_option('header', array(
'test_access' => array(
'id' => 'test_access',
'table' => 'views',
'field' => 'test_access',
'custom_access' => FALSE,
),
));
$view->init_display();
$view->init_handlers();
$handlers = $view->display_handler->get_handlers('header');
$this->assertEqual(0, count($handlers));
$view->destroy();
$view = $this->getBasicView();
// add a test area
$view->display['default']->handler->override_option('header', array(
'test_access' => array(
'id' => 'test_access',
'table' => 'views',
'field' => 'test_access',
'custom_access' => TRUE,
),
));
$view->init_display();
$view->init_handlers();
$handlers = $view->display_handler->get_handlers('header');
$this->assertEqual(1, count($handlers));
$this->assertTrue(isset($handlers['test_access']));
}
}

View File

@@ -0,0 +1,28 @@
<?php
/**
* @file
* Contains views_test_area_access
*/
class views_test_area_access extends views_handler_area {
/**
* {@inheritdoc}
*/
function access() {
return $this->options['custom_access'];
}
/**
* {@inheritdoc}
*/
function option_definition() {
$options = parent::option_definition();
$options['custom_access'] = array('default' => TRUE, 'bool' => TRUE);
return $options;
}
}

View File

@@ -241,4 +241,68 @@ class ViewsCacheTest extends ViewsSqlTest {
$this->assertEqual($first_content_type, $second_content_type, t('Content types of responses are equal.'));
}
/**
* Test caching of different exposed filter values with the same view result.
*
* Make sure the output is different.
*/
function testExposedFilterSameResultsCaching() {
// Create the view with time-based cache with hour lifetimes and add exposed
// filter to it with "Starts with" operator.
$view = $this->getBasicView();
$view->set_display();
$view->display_handler->override_option('cache', array(
'type' => 'time',
'results_lifespan' => '3600',
'output_lifespan' => '3600',
));
$view->display_handler->override_option('filters', array(
'name' => array(
'id' => 'name',
'table' => 'views_test',
'field' => 'name',
'relationship' => 'none',
'operator' => 'starts',
'exposed' => TRUE,
'expose' => array(
'operator_id' => 'name_op',
'operator' => 'name_op',
'identifier' => 'name',
),
),
));
// Clone the view before setting exposed input.
$clone = $view->copy();
// Pass "Rin" to the exposed filter and check that only one row returned.
$view->set_exposed_input(array(
'name' => 'Rin',
));
$this->executeView($view);
$first_result = $view->result;
$first_output = $view->render();
$this->assertEqual(1, count($first_result), t('The number of rows returned by the first view match.'));
// Pass full "Ringo" to the exposed filter at the second time and make sure
// results are the same.
$clone->set_exposed_input(array(
'name' => 'Ringo',
));
$this->executeView($clone);
$second_result = $clone->result;
$second_output = $clone->render();
$this->assertEqual($first_result, $second_result, t('Results of both views are the same.'));
// Check that output is not the same and it contains full "Ringo" word in
// default value of exposed input.
$this->assertNotEqual($first_output, $second_output, t('Output of the second view is different.'));
$this->drupalSetContent($second_output);
$element = $this->xpath('//input[@name="name" and @value="Ringo"]');
$this->assertTrue(!empty($element), t('Input field of exposed filter has the second value.'));
$view->destroy();
$clone->destroy();
}
}

View File

@@ -151,6 +151,51 @@ class ViewsModuleTest extends ViewsSqlTest {
$this->assertEqual('views_handler_filter', get_class($handler));
}
/**
* Tests views_fetch_data().
*/
function testFetchData() {
// Make sure we start with a empty cache.
$this->resetStaticViewsDataCache();
cache_clear_all('*', 'cache_views', TRUE);
variable_set('views_test_views_data_count', 0);
// Request info about an existing table.
$this->assertTrue(views_fetch_data('views_test'), 'Data about existing table returned');
// This should have triggered a views data rebuild, and written a cache
// entry for all tables and the requested table but no other tables.
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
$this->assertTrue(cache_get('views_data:en', 'cache_views'), 'Cache for all tables written.');
$this->assertTrue(cache_get('views_data:views_test:en', 'cache_views'), 'Cache for requested table written.');
$this->assertFalse(cache_get('views_data:views_test_previous:en', 'cache_views'), 'No Cache written for not requested table.');
$this->assertTrue(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is fully loaded');
$this->resetStaticViewsDataCache();
// Request the same table again.
$this->assertTrue(views_fetch_data('views_test'), 'Data about existing table returned');
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
$this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
$this->resetStaticViewsDataCache();
// Request a missing table, this should load the full cache from cache but
// not rebuilt.
$this->assertFalse(views_fetch_data('views_test_missing'), 'No data about missing table returned');
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
$this->assertTrue(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is fully loaded');
$this->resetStaticViewsDataCache();
// Request the same empty table again, this should load only that (empty)
// cache for that table.
$this->assertFalse(views_fetch_data('views_test_missing'), 'No data about missing table returned');
$this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
$this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
}
/**
* Ensure that a certain handler is a instance of a certain table/field.
*/
@@ -160,4 +205,13 @@ class ViewsModuleTest extends ViewsSqlTest {
$this->assertEqual($field_data['handler'], get_class($handler));
}
/**
* Resets the views data cache.
*/
protected function resetStaticViewsDataCache() {
drupal_static_reset('_views_fetch_data_cache');
drupal_static_reset('_views_fetch_data_recursion_protected');
drupal_static_reset('_views_fetch_data_fully_loaded');
}
}

View File

@@ -5,9 +5,9 @@ core = 7.x
dependencies[] = views
hidden = TRUE
; Information added by drupal.org packaging script on 2013-02-04
version = "7.x-3.5+38-dev"
; Information added by Drupal.org packaging script on 2015-02-11
version = "7.x-3.10"
core = "7.x"
project = "views"
datestamp = "1359942791"
datestamp = "1423648085"

View File

@@ -31,6 +31,10 @@ function views_test_views_api() {
* Implements hook_views_data().
*/
function views_test_views_data() {
// Count how often this hook is called.
$count = variable_get('views_test_views_data_count', 0);
$count++;
variable_set('views_test_views_data_count', $count);
return variable_get('views_test_views_data', array());
}

View File

@@ -114,7 +114,6 @@ class ViewsTranslatableTest extends ViewsSqlTest {
'more1' => array('use_more_text'),
'Reset1' => array('exposed_form', 'reset_button_label'),
'Offset1' => array('pager', 'expose', 'offset_label'),
'Master1' => array('title'),
'title1' => array('title'),
'Tag first1' => array('pager', 'tags', 'first'),
'Tag prev1' => array('pager', 'tags', 'previous'),
@@ -124,9 +123,23 @@ class ViewsTranslatableTest extends ViewsSqlTest {
'fieldlabel1' => array('field', 'node', 'nid', 'label'),
'filterlabel1' => array('filter', 'node', 'nid', 'expose', 'label'),
'- All -' => array('pager', 'expose', 'items_per_page_options_all_label'),
'Header1' => array('header', 'views', 'area', 'content'),
);
$formats = array(
'Header1' => 'filtered_html',
);
foreach ($translatables as $translatable) {
$this->assertEqual($translatable['keys'], $this->string_keys[$translatable['value']]);
// Make sure the format is correct.
if (isset($formats[$translatable['value']])) {
$this->assertEqual($translatable['format'], $formats[$translatable['value']]);
}
else {
$this->assertNull($translatable['format'], 'No format defined');
}
}
}
}
@@ -169,6 +182,14 @@ class ViewsTranslatableTest extends ViewsSqlTest {
$handler->display->display_options['pager']['options']['expose']['offset_label'] = 'Offset1';
$handler->display->display_options['style_plugin'] = 'default';
$handler->display->display_options['row_plugin'] = 'fields';
/* Global: Header */
$handler->display->display_options['header']['area']['id'] = 'area';
$handler->display->display_options['header']['area']['table'] = 'views';
$handler->display->display_options['header']['area']['field'] = 'area';
$handler->display->display_options['header']['area']['empty'] = FALSE;
$handler->display->display_options['header']['area']['content'] = 'Header1';
$handler->display->display_options['header']['area']['format'] = 'filtered_html';
$handler->display->display_options['header']['area']['tokenize'] = 0;
/* Field: Content: Nid */
$handler->display->display_options['fields']['nid']['id'] = 'nid';
$handler->display->display_options['fields']['nid']['table'] = 'node';