Issue #3247935 by mfb: drupal_add_html_head_link(): URL in link HTTP header should not be HTML-encoded
parent
dede132f8e
commit
d563595da8
|
@ -2965,7 +2965,7 @@ function drupal_add_html_head_link($attributes, $header = FALSE) {
|
|||
|
||||
if ($header) {
|
||||
// Also add a HTTP header "Link:".
|
||||
$href = '<' . check_plain($attributes['href']) . '>;';
|
||||
$href = '<' . $attributes['href'] . '>;';
|
||||
unset($attributes['href']);
|
||||
$element['#attached']['drupal_add_http_header'][] = array('Link', $href . drupal_http_header_attributes($attributes), TRUE);
|
||||
}
|
||||
|
|
|
@ -3342,12 +3342,15 @@ class DrupalAddHtmlHeadLinkTest extends DrupalWebTestCase {
|
|||
'</foo?bar=baz>; rel="alternate"',
|
||||
'</foo/bar>; hreflang="nl"; rel="alternate"',
|
||||
'</foo/bar>; hreflang="de"; rel="alternate"',
|
||||
'</foo?bar=baz&baz=false>; hreflang="en"; rel="alternate"',
|
||||
));
|
||||
$this->assertEqual($this->drupalGetHeader('Link'), $expected_link_header);
|
||||
|
||||
// Check that duplicate alternate URLs with different hreflangs are allowed.
|
||||
$test_link = $this->xpath('//head/link[@rel="alternate"][@href="/foo/bar"]');
|
||||
$this->assertEqual(count($test_link), 2, 'Duplicate alternate URLs are allowed.');
|
||||
// Check that link element attributes are HTML-encoded.
|
||||
$this->assertRaw('<link href="/foo?bar=baz&baz=false" hreflang="en" rel="alternate" />');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -343,5 +343,10 @@ function common_test_html_head_link() {
|
|||
'hreflang' => 'de',
|
||||
'rel' => 'alternate',
|
||||
), TRUE);
|
||||
drupal_add_html_head_link(array(
|
||||
'href' => '/foo?bar=baz&baz=false',
|
||||
'hreflang' => 'en',
|
||||
'rel' => 'alternate',
|
||||
), TRUE);
|
||||
return '';
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue