From 7015fae91c3578f875fbb914e894bbe926156bbf Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 30 Nov 2021 15:02:22 +0100 Subject: [PATCH] only allow to click on valid website URLs closes #8827 --- modules/ui/fields/input.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/ui/fields/input.js b/modules/ui/fields/input.js index d5bec7405..e7d24972c 100644 --- a/modules/ui/fields/input.js +++ b/modules/ui/fields/input.js @@ -182,11 +182,17 @@ export function uiFieldText(field, context) { function validIdentifierValueForLink() { - const value = utilGetSetValue(input).trim().split(';')[0]; + const value = utilGetSetValue(input).trim(); - if (field.type === 'url' && value) return value; + if (field.type === 'url' && value) { + try { + return (new URL(value)).href; + } catch (e) { + return null; + } + } if (field.type === 'identifier' && field.pattern) { - return value && value.match(new RegExp(field.pattern)); + return value && value.match(new RegExp(field.pattern))[0]; } return null; }