diff --git a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php index a9c254a1552..91764810313 100644 --- a/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php +++ b/core/lib/Drupal/Core/Render/HtmlResponseAttachmentsProcessor.php @@ -10,7 +10,6 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\EnforcedResponseException; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManagerInterface; -use Drupal\Component\Utility\Html; use Symfony\Component\HttpFoundation\RequestStack; /** @@ -420,7 +419,10 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn * @param array $html_head_link * The 'html_head_link' value of a render array. Each head link is specified * by a two-element array: - * - An array specifying the attributes of the link. + * - An array specifying the attributes of the link. The 'href' and 'rel' + * attributes are required, and the 'href' attribute is expected to be a + * percent-encoded URI for proper serialization in the Link: HTTP header, + * as specified by RFC 8288. * - A boolean specifying whether the link should also be a Link: HTTP * header. * @@ -455,7 +457,7 @@ class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorIn if ($should_add_header) { // Also add a HTTP header "Link:". - $href = '<' . Html::escape($attributes['href']) . '>'; + $href = '<' . $attributes['href'] . '>'; unset($attributes['href']); if ($param = static::formatHttpHeaderAttributes($attributes)) { $href .= ';' . $param; diff --git a/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php index 9e8e86600c5..885443ec15f 100644 --- a/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php +++ b/core/modules/system/tests/src/Functional/Render/HtmlResponseAttachmentsTest.php @@ -63,7 +63,7 @@ class HtmlResponseAttachmentsTest extends BrowserTestBase { // Test ['#attached']['html_head_link'] when outputted as HTTP header. $this->drupalGet('/render_attached_test/html_header_link'); $expected_link_headers = [ - '; rel="alternate"', + '&baz=false>; rel="alternate"', '; hreflang="nl"; rel="alternate"', '; hreflang="de"; rel="alternate"', ];