diff --git a/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php b/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
index 7bb0fb1..7ec5fc0 100644
--- a/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
+++ b/core/modules/system/tests/modules/test_page_test/src/Controller/Test.php
@@ -98,4 +98,14 @@ public function renderEncodedMarkup() {
return ['#plain_text' => 'Bad html '];
}
+ /**
+ * Renders a page with pipe character in link test.
+ *
+ * @return array
+ * A render array as expected by drupal_render()
+ */
+ public function renderPipeInLink() {
+ return ['#markup' => 'foo|bar|baz'];
+ }
+
}
diff --git a/core/modules/system/tests/modules/test_page_test/test_page_test.routing.yml b/core/modules/system/tests/modules/test_page_test/test_page_test.routing.yml
index cbcf6d8..9d07a34 100644
--- a/core/modules/system/tests/modules/test_page_test/test_page_test.routing.yml
+++ b/core/modules/system/tests/modules/test_page_test/test_page_test.routing.yml
@@ -66,3 +66,11 @@ test_page_test.encoded:
_controller: '\Drupal\test_page_test\Controller\Test::renderEncodedMarkup'
requirements:
_access: 'TRUE'
+
+test_page_test.pipe:
+ path: '/test-pipe-char'
+ defaults:
+ _title: 'Page with pipe char in link'
+ _controller: '\Drupal\test_page_test\Controller\Test::renderPipeInLink'
+ requirements:
+ _access: 'TRUE'
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index b0a53dd..c53647c 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -113,6 +113,16 @@ public function testError() {
}
/**
+ * Tests linkExists() with pipe character (|) in locator.
+ *
+ * @see \Drupal\Tests\WebAssert::linkExists()
+ */
+ public function testPipeCharInLocator() {
+ $this->drupalGet('test-pipe-char');
+ $this->assertSession()->linkExists('foo|bar|baz');
+ }
+
+ /**
* Tests legacy asserts.
*/
public function testLegacyAsserts() {