diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -13,10 +13,8 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Drupal\Component\Utility\Unicode; -use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Config; use Drupal\Core\Config\StorageException; -use Drupal\Core\Render\SafeString; use Drupal\Core\Template\Attribute; use Drupal\Core\Theme\ThemeSettings; use Drupal\Component\Utility\NestedArray; @@ -1067,25 +1065,6 @@ } /** - * Prepares variables for inline list templates. - * - * Default template: inline-list.html.twig. - * - * @param array $variables - * An associative array containing: - * - items: An array of items to be displayed in the list. - * - separator: A string to separate list items. - * - empty: A message to display when there are no items. - * - * @see https://www.drupal.org/node/1842756 - */ -function template_preprocess_inline_list(&$variables) { - // Since the separator may be user-specified, it must be filtered to permit - // some HTML (such as
) to pass through. - $variables['separator'] = SafeString::create(Xss::filter($variables['separator'], ['br'])); -} - -/** * Returns HTML for an indentation div; used for drag and drop tables. * * @param $variables @@ -1751,7 +1730,7 @@ 'variables' => array('items' => array(), 'title' => '', 'list_type' => 'ul', 'attributes' => array(), 'empty' => NULL, 'context' => array()), ), 'inline_list' => array( - 'variables' => array('items' => array(), 'separator' => ', ', 'attributes' => array(), 'empty' => NULL), + 'variables' => array('items' => array(), 'separator' => ', '), ), 'feed_icon' => array( 'variables' => array('url' => NULL, 'title' => NULL), diff -u b/core/modules/system/src/Tests/Theme/FunctionsTest.php b/core/modules/system/src/Tests/Theme/FunctionsTest.php --- b/core/modules/system/src/Tests/Theme/FunctionsTest.php +++ b/core/modules/system/src/Tests/Theme/FunctionsTest.php @@ -176,39 +176,18 @@ $expected = ''; $this->assertThemeOutput('inline_list', $variables, $expected, 'Empty %callback generates no output.'); - // Verify that empty items produce the empty string. + // Verify that elements are correctly delimited by commas by default. $variables = array(); - $variables['empty'] = 'No items found.'; - $expected = 'No items found.'; - $this->assertThemeOutput('inline_list', $variables, $expected, 'Empty %callback generates empty string.'); - - // Verify that empty text is not displayed when there are list items. - $variables = array(); - $variables['empty'] = 'No items found.'; $variables['items'] = array('Rabbit', 'rabbit', 'rabbit'); $expected = 'Rabbit, rabbit, rabbit'; - $this->assertThemeOutput('inline_list', $variables, $expected, '%callback does not print empty text when there are list items.'); - - // Verify that a non-default separator is rendered. - $variables = array(); - $variables['items'] = array('Un', 'Deux', 'Trois'); - $variables['separator'] = ' and '; - $expected = 'Un and Deux and Trois'; - $this->assertThemeOutput('inline_list', $variables, $expected, '%callback uses a custom separator when provided.'); + $this->assertThemeOutput('inline_list', $variables, $expected, '%callback elements are correctly delimited by commas by default.'); - // Verify that HTML separators are properly rendered. + // Verify that HTML separators are escaped. $variables = array(); $variables['items'] = array('Doe', 'Buck', 'Kit'); - $variables['separator'] = '
'; - $expected = 'Doe
Buck
Kit'; + $variables['separator'] = '<br /gt;'; + $expected = 'Doe<br />Buck<br /gt;Kit'; $this->assertThemeOutput('inline_list', $variables, $expected, '%callback allows HTML in user-provided separators.'); - - // Verify that the separator is sanitized. - $variables = array(); - $variables['items'] = array('Un', 'Deux', 'Trois'); - $variables['separator'] = ''; - $expected = 'Unalert("test")Deuxalert("test")Trois'; - $this->assertThemeOutput('inline_list', $variables, $expected, '%callback sanitizes user-provided separators.'); } /** diff -u b/core/modules/system/templates/inline-list.html.twig b/core/modules/system/templates/inline-list.html.twig --- b/core/modules/system/templates/inline-list.html.twig +++ b/core/modules/system/templates/inline-list.html.twig @@ -3,18 +3,14 @@ * @file - * Default theme implementation for an inline list of items. + * Default theme implementation for a comma-delimited list of items. * * Available variables: * - items: A list of items. - * - separator: A delimiter to separate the items in the list. - * - empty: A message to display when there are no items. - * - * @see template_preprocess_inline_list() + * - separator: A delimiter to separate the items in the list. Defaults + * to a comma followed by a space (", "). * * @ingroup themeable */ #} {%- for item in items -%} {{ item }}{{ loop.last ? '' : separator }} -{%- else -%} - {{- empty -}} {%- endfor -%}