summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2018-06-14 14:00:17 (GMT)
committerAlex Pott2018-06-14 14:00:17 (GMT)
commitb98cdcad61d46fce8e31b3a39fde128da40f9f62 (patch)
tree1272cafe66c40d782451488e79ab9aa0989a2239
parent4a03584d2f56a706db1eee3a10a2797cde830855 (diff)
Issue #2927723 by longwave, artreaktor, chiranjeeb2410, ankitjain28may, cilefen, dawehner: The URL "/ " with trailing space is not getting recognized as <front>
-rw-r--r--core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php2
-rw-r--r--core/modules/link/tests/src/Functional/LinkFieldTest.php6
2 files changed, 6 insertions, 2 deletions
diff --git a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
index 3a12413..ee3b77d 100644
--- a/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
+++ b/core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php
@@ -101,7 +101,7 @@ class LinkWidget extends WidgetBase {
*/
protected static function getUserEnteredStringAsUri($string) {
// By default, assume the entered string is an URI.
- $uri = $string;
+ $uri = trim($string);
// Detect entity autocomplete string, map to 'entity:' URI.
$entity_id = EntityAutocomplete::extractEntityIdFromAutocompleteInput($string);
diff --git a/core/modules/link/tests/src/Functional/LinkFieldTest.php b/core/modules/link/tests/src/Functional/LinkFieldTest.php
index fc6c9fe..4df94dd 100644
--- a/core/modules/link/tests/src/Functional/LinkFieldTest.php
+++ b/core/modules/link/tests/src/Functional/LinkFieldTest.php
@@ -121,6 +121,10 @@ class LinkFieldTest extends BrowserTestBase {
'/?example=llama' => '&lt;front&gt;?example=llama',
'/#example' => '&lt;front&gt;#example',
+ // Trailing spaces should be ignored.
+ '/ ' => '&lt;front&gt;',
+ '/path with spaces ' => '/path with spaces',
+
// @todo '<front>' is valid input for BC reasons, may be removed by
// https://www.drupal.org/node/2421941
'<front>' => '&lt;front&gt;',
@@ -200,7 +204,7 @@ class LinkFieldTest extends BrowserTestBase {
preg_match('|entity_test/manage/(\d+)|', $this->getUrl(), $match);
$id = $match[1];
$this->assertText(t('entity_test @id has been created.', ['@id' => $id]));
- $this->assertRaw($string);
+ $this->assertRaw('"' . $string . '"');
}
}