diff --git a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php index 13e5884..c4abe86 100644 --- a/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php +++ b/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php @@ -184,13 +184,13 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte if (!empty($main_content)) { $this->renderer->executeInRenderContext(new RenderContext(), function() use (&$main_content) { + // Ensure that we at least store the page title in cache. + $main_content['#cache_properties'][] = '#title'; return $this->renderer->render($main_content, FALSE); }); $main_content = $this->renderCache->getCacheableRenderArray($main_content) + [ '#title' => isset($main_content['#title']) ? $main_content['#title'] : NULL ]; - // Ensure that we at least store the page title in cache. - $main_content['#cache_properties'][] = '#title'; } // Instantiate the page display, and give it the main content. diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index b91b2b4..9dea747 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -43,7 +43,7 @@ protected function setUp() { /** * Tests the handling of HTML in node titles. */ - function ptestTitleTags() { + function testTitleTags() { $title = "string with HTML"; // Generate node content. $edit = array( @@ -62,7 +62,7 @@ function ptestTitleTags() { /** * Test if the title of the site is XSS proof. */ - function ptestTitleXSS() { + function testTitleXSS() { // Set some title with JavaScript and HTML chars to escape. $title = ' & < > " \' '; $title_filtered = SafeMarkup::checkPlain($title);