summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2016-10-23 13:40:40 -0700
committerAlex Pott2016-10-23 13:40:40 -0700
commitf08a96ea683883ed0a81ae7e8f1b1bc72edca6a6 (patch)
tree4efee90ac2d4775d96f5973bfad629824aaefc9b
parent515a55e75f6c67d48bce20fc4da39b17a2e80a9b (diff)
Issue #2819593 by dawehner, webflo: Link title double escaping in Link::preRenderLink
-rw-r--r--core/lib/Drupal/Core/Render/Element/Link.php2
-rw-r--r--core/modules/system/src/Tests/Theme/EngineTwigTest.php2
-rw-r--r--core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.link_generator.html.twig2
3 files changed, 5 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Render/Element/Link.php b/core/lib/Drupal/Core/Render/Element/Link.php
index 535d9bb..3888c79 100644
--- a/core/lib/Drupal/Core/Render/Element/Link.php
+++ b/core/lib/Drupal/Core/Render/Element/Link.php
@@ -92,7 +92,7 @@ class Link extends RenderElement {
/** @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);
}
diff --git a/core/modules/system/src/Tests/Theme/EngineTwigTest.php b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
index a79c01d..51d092d 100644
--- a/core/modules/system/src/Tests/Theme/EngineTwigTest.php
+++ b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
@@ -77,6 +77,7 @@ class EngineTwigTest extends WebTestBase {
$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 @@ class EngineTwigTest extends WebTestBase {
'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:
diff --git a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.link_generator.html.twig b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.link_generator.html.twig
index 5d20ce2..a836aec 100644
--- a/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.link_generator.html.twig
+++ b/core/modules/system/tests/modules/twig_theme_test/templates/twig_theme_test.link_generator.html.twig
@@ -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>