Commit 797f9d2d authored by alexpott's avatar alexpott
Browse files

Revert "Issue #2369987 by aneek, joelpittet, rteijeiro, jain_deepak, pgautam,...

Revert "Issue #2369987 by aneek, joelpittet, rteijeiro, jain_deepak, pgautam, idebr: Remove SafeMarkup::set() from 'head' title on template_preprocess_html"

This reverts commit 10c8777e.
parent 9a36faf6
...@@ -1267,8 +1267,8 @@ function template_preprocess_html(&$variables) { ...@@ -1267,8 +1267,8 @@ function template_preprocess_html(&$variables) {
// Construct page title. // Construct page title.
if (!empty($variables['page']['#title'])) { if (!empty($variables['page']['#title'])) {
$head_title = array( $head_title = array(
'title' => trim(strip_tags($variables['page']['#title'])), 'title' => SafeMarkup::set(trim(strip_tags($variables['page']['#title']))),
'name' => $site_config->get('name'), 'name' => SafeMarkup::checkPlain($site_config->get('name')),
); );
} }
// @todo Remove once views is not bypassing the view subscriber anymore. // @todo Remove once views is not bypassing the view subscriber anymore.
...@@ -1276,19 +1276,24 @@ function template_preprocess_html(&$variables) { ...@@ -1276,19 +1276,24 @@ function template_preprocess_html(&$variables) {
elseif ($is_front_page) { elseif ($is_front_page) {
$head_title = array( $head_title = array(
'title' => t('Home'), 'title' => t('Home'),
'name' => $site_config->get('name'), 'name' => SafeMarkup::checkPlain($site_config->get('name')),
); );
} }
else { else {
$head_title = ['name' => $site_config->get('name')]; $head_title = array('name' => SafeMarkup::checkPlain($site_config->get('name')));
if ($site_config->get('slogan')) { if ($site_config->get('slogan')) {
$head_title['slogan'] = strip_tags($site_config->get('slogan')); $head_title['slogan'] = strip_tags(Xss::filterAdmin($site_config->get('slogan')));
} }
} }
$variables['head_title'] = $head_title;
// @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
$variables['head_title_array'] = $head_title; $variables['head_title_array'] = $head_title;
$output = '';
$separator = '';
foreach ($head_title as $item) {
$output .= $separator . SafeMarkup::escape($item);
$separator = ' | ';
}
$variables['head_title'] = SafeMarkup::set($output);
// Collect all attachments. This must happen in the preprocess function for // Collect all attachments. This must happen in the preprocess function for
// #type => html, to ensure that attachments added in #pre_render callbacks // #type => html, to ensure that attachments added in #pre_render callbacks
...@@ -1486,8 +1491,11 @@ function template_preprocess_install_page(&$variables) { ...@@ -1486,8 +1491,11 @@ function template_preprocess_install_page(&$variables) {
// Override the site name that is displayed on the page, since Drupal is // Override the site name that is displayed on the page, since Drupal is
// still in the process of being installed. // still in the process of being installed.
$distribution_name = drupal_install_profile_distribution_name(); $distribution_name = SafeMarkup::checkPlain(drupal_install_profile_distribution_name());
$variables['site_name'] = $distribution_name; $variables['site_name'] = $distribution_name;
$variables['head_title_array']['name'] = $distribution_name;
$variables['head_title'] = implode(' | ', $variables['head_title_array']);
} }
/** /**
......
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
* - css: A list of CSS files for the current page. * - css: A list of CSS files for the current page.
* - head: Markup for the HEAD element (including meta tags, keyword tags, and * - head: Markup for the HEAD element (including meta tags, keyword tags, and
* so on). * so on).
* - head_title: List of text elements that make up the head_title variable. * - head_title: A modified version of the page title, for use in the TITLE tag.
* May contain or more of the following: * - head_title_array: List of text elements that make up the head_title
* variable. May contain or more of the following:
* - title: The title of the page. * - title: The title of the page.
* - name: The name of the site. * - name: The name of the site.
* - slogan: The slogan of the site. * - slogan: The slogan of the site.
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
<html{{ html_attributes }}> <html{{ html_attributes }}>
<head> <head>
{{ head }} {{ head }}
<title>{{ head_title|safe_join(' | ') }}</title> <title>{{ head_title }}</title>
{{ styles }} {{ styles }}
{{ scripts }} {{ scripts }}
</head> </head>
......
...@@ -10,8 +10,9 @@ ...@@ -10,8 +10,9 @@
* - css: A list of CSS files for the current page. * - css: A list of CSS files for the current page.
* - head: Markup for the HEAD element (including meta tags, keyword tags, and * - head: Markup for the HEAD element (including meta tags, keyword tags, and
* so on). * so on).
* - head_title: List of text elements that make up the head_title variable. * - head_title: A modified version of the page title, for use in the TITLE tag.
* May contain or more of the following: * - head_title_array: List of text elements that make up the head_title
* variable. May contain or more of the following:
* - title: The title of the page. * - title: The title of the page.
* - name: The name of the site. * - name: The name of the site.
* - slogan: The slogan of the site. * - slogan: The slogan of the site.
...@@ -39,7 +40,7 @@ ...@@ -39,7 +40,7 @@
<html{{ html_attributes }}> <html{{ html_attributes }}>
<head> <head>
{{ head }} {{ head }}
<title>{{ head_title|safe_join(' | ') }}</title> <title>{{ head_title }}</title>
{{ styles }} {{ styles }}
{{ scripts }} {{ scripts }}
</head> </head>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment