diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index c50e320..7ef8722 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -12,6 +12,7 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Render\BubbleableMetadata; +use Drupal\Component\Utility\Html; use Drupal\Component\Utility\SafeMarkup; use Symfony\Component\HttpFoundation\RequestStack; @@ -40,7 +41,6 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn * Provided so that we can support drupal_processed_attached() as an API. * * @var array - * @todo Remove this in Drupal 9. */ public static $legacyAttached; @@ -411,8 +411,7 @@ protected function processHtmlHeadLink(array $html_head_link) { if ($should_add_header) { // Also add a HTTP header "Link:". - // @todo: Change this to Html::escape() after https://www.drupal.org/node/2550945 - $href = '<' . SafeMarkup::checkPlain($attributes['href']) . '>;'; + $href = '<' . Html::escape($attributes['href'] . '>'); unset($attributes['href']); $attached['http_header'][] = ['Link', $href . drupal_http_header_attributes($attributes), TRUE]; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index 47eac67..cd1e580 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -468,9 +468,6 @@ function template_preprocess_book_export_html(&$variables) { $variables['base_url'] = $base_url; $variables['language'] = $language_interface; $variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL); - // @todo: Commenting out the following line is wrong. - // @see https://www.drupal.org/node/1338858 - // $variables['head'] = drupal_get_html_head(); // HTML element attributes. $attributes = array(); diff --git a/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php b/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php index 3571efb..02497fb 100644 --- a/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php +++ b/core/modules/system/src/Tests/Render/HtmlResponseAttachmentsTest.php @@ -47,13 +47,21 @@ public function testAttachments() { $this->assertHeader('X-Drupal-Cache', 'HIT'); // Test ['#attached']['feed']. - // @todo: Improve this test. $this->drupalGet('/render_attached_test/feed'); - $this->assertEqual(1, count($this->xpath('//head/link[@rel="alternate"]')), 'Link has rel="alternate"'); - $this->assertEqual(1, count($this->xpath('//head/link[@type="application/rss+xml"]')), 'Link has proper content type.'); - $this->assertEqual(1, count($this->xpath('//head/link[@href="test://url"]')), 'Link has URL.'); - $this->assertEqual(1, count($this->xpath('//head/link[@title=""]')), 'Link has title.'); - $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Discover the DOM element for the feed link. + $link = $this->xpath('//head/link[@href="test://url"]'); + $this->assertEqual(1, count($link), 'Link has URL.'); + // Reconcile the other attributes. + $link_attributes = [ + 'href' => 'test://url', + 'rel' => 'alternate', + 'type' => 'application/rss+xml', + 'title' => '', + ]; + $link = reset($link); + foreach ($link->attributes() as $attribute => $value) { + $this->assertEqual($value, $link_attributes[$attribute]); + } // Repeat for the cache. $this->drupalGet('/render_attached_test/feed'); $this->assertHeader('X-Drupal-Cache', 'HIT'); @@ -79,13 +87,15 @@ public function testAttachments() { $this->assertHeader('X-Drupal-Cache', 'HIT'); // Test ['#attached']['feed']. - // @todo: Improve this test. $this->drupalGet('/render_attached_test/feed_dpa'); - $this->assertEqual(1, count($this->xpath('//head/link[@rel="alternate"]')), 'Link has rel="alternate"'); - $this->assertEqual(1, count($this->xpath('//head/link[@type="application/rss+xml"]')), 'Link has proper content type.'); - $this->assertEqual(1, count($this->xpath('//head/link[@href="test://url"]')), 'Link has URL.'); - $this->assertEqual(1, count($this->xpath('//head/link[@title=""]')), 'Link has title.'); - $this->assertHeader('X-Drupal-Cache', 'MISS'); + // Discover the DOM element for the feed link. + $link = $this->xpath('//head/link[@href="test://url"]'); + $this->assertEqual(1, count($link), 'Link has URL.'); + // Reconcile the other attributes. + $link = reset($link); + foreach ($link->attributes() as $attribute => $value) { + $this->assertEqual($value, $link_attributes[$attribute]); + } // Repeat for the cache. $this->drupalGet('/render_attached_test/feed_dpa'); $this->assertHeader('X-Drupal-Cache', 'HIT');