Commit f08a96ea authored by alexpott's avatar alexpott

Issue #2819593 by dawehner, webflo: Link title double escaping in Link::preRenderLink

parent 515a55e7
......@@ -92,7 +92,7 @@ public static function preRenderLink($element) {
/** @var \Drupal\Core\Utility\LinkGenerator $link_generator */
$link_generator = \Drupal::service('link_generator');
$generated_link = $link_generator->generate($element['#title'], $element['#url']->setOptions($options));
$element['#markup'] = $generated_link->getGeneratedLink();
$element['#markup'] = $generated_link;
$generated_link->merge(BubbleableMetadata::createFromRenderArray($element))
->applyTo($element);
}
......
......@@ -77,6 +77,7 @@ public function testTwigLinkGenerator() {
$link_generator = $this->container->get('link_generator');
$generated_url = Url::fromRoute('user.register', [], ['absolute' => TRUE])->toString(TRUE)->getGeneratedUrl();
$expected = [
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE])),
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['absolute' => TRUE, 'attributes' => ['foo' => 'bar']])),
......@@ -84,6 +85,7 @@ public function testTwigLinkGenerator() {
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['id' => 'kitten']])),
'link via the linkgenerator: ' . $link_generator->generate('register', new Url('user.register', [], ['attributes' => ['class' => ['llama', 'kitten', 'panda']]])),
'link via the linkgenerator: ' . $link_generator->generate(Markup::create('<span>register</span>'), new Url('user.register', [], ['absolute' => TRUE])),
'link via the linkgenerator: <a href="' . $generated_url . '"><span>register</span><svg></svg></a>',
];
// Verify that link() has the ability to bubble cacheability metadata:
......
......@@ -5,3 +5,5 @@
<div>link via the linkgenerator: {{ link('register', 'route:user.register', attributes) }}</div>
{% set title %}<span>register</span>{% endset %}
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>
{% set title %}<span>register</span><svg></svg>{% endset %}
<div>link via the linkgenerator: {{ link(title, test_url) }}</div>
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