From 7d9c1f3f3096f72033adc18c8250415e3d89dfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gu=CC=88nther?= Date: Thu, 26 Sep 2024 15:35:14 +0200 Subject: [PATCH 1/2] BUGFIX: Trim leading and tailing whitespaces Whitespaces like a tab can lead to a 404 error if a URL has been pasted to a LinkEditor or LinkInput. As datasources, assets, URLs and slugs should not start with a whitespace, we can remove them. Fixes: #3859 --- packages/neos-ui-editors/src/Library/LinkInput.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/neos-ui-editors/src/Library/LinkInput.js b/packages/neos-ui-editors/src/Library/LinkInput.js index af590598d6..abad8084cc 100644 --- a/packages/neos-ui-editors/src/Library/LinkInput.js +++ b/packages/neos-ui-editors/src/Library/LinkInput.js @@ -149,6 +149,10 @@ export default class LinkInput extends PureComponent { } handleSearchTermChange = searchTerm => { + // trim leading and trailing whitespace as it can cause issues + // with the further processing + searchTerm.trim() + this.setState({searchTerm}); if (isUriOrInternalLink(searchTerm)) { From 9e59a3c6eeb4fee87ca4afe19106203f4f1c7f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gu=CC=88nther?= Date: Thu, 26 Sep 2024 15:59:06 +0200 Subject: [PATCH 2/2] BUGFIX: Prevent potential js error Ensure that searchTerm is a string before trimming the value. --- packages/neos-ui-editors/src/Library/LinkInput.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/neos-ui-editors/src/Library/LinkInput.js b/packages/neos-ui-editors/src/Library/LinkInput.js index abad8084cc..af8d649d39 100644 --- a/packages/neos-ui-editors/src/Library/LinkInput.js +++ b/packages/neos-ui-editors/src/Library/LinkInput.js @@ -151,7 +151,9 @@ export default class LinkInput extends PureComponent { handleSearchTermChange = searchTerm => { // trim leading and trailing whitespace as it can cause issues // with the further processing - searchTerm.trim() + if (typeof searchTerm === 'string') { + searchTerm.trim() + } this.setState({searchTerm});