aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas <jonas@freesources.org>2024-03-05 12:10:22 +0100
committerJonas <jonas@freesources.org>2024-03-06 09:59:42 +0100
commit02694411a8baf34053bbce4b120b2ee0bfe09d7c (patch)
tree587b3c3c2b4e7f6277ab5dca7eae11c6dcefd705
parent14ef17e5e21017b36ff106eb9202a0cd54771199 (diff)
downloadnextcloud-server-02694411a8baf34053bbce4b120b2ee0bfe09d7c.tar.gz
nextcloud-server-02694411a8baf34053bbce4b120b2ee0bfe09d7c.zip
fix: Make URL pattern regexes match localhost and URLs with ports
E.g. the file reference widget should work with links to Nextcloud on localhost. This adjusts the URL pattern regexes in server to be in sync with the ones in `@nextcloud/vue`. See nextcloud-libraries/nextcloud-vue#5176 for further details. Signed-off-by: Jonas <jonas@freesources.org>
-rw-r--r--core/src/OCP/comments.js2
-rw-r--r--lib/public/IURLGenerator.php2
2 files changed, 2 insertions, 2 deletions
diff --git a/core/src/OCP/comments.js b/core/src/OCP/comments.js
index cd1e8a8fa77..9e182aeef3e 100644
--- a/core/src/OCP/comments.js
+++ b/core/src/OCP/comments.js
@@ -34,7 +34,7 @@ import $ from 'jquery'
*
* This is a copy of the backend regex in IURLGenerator, make sure to adjust both when changing
*/
-const urlRegex = /(\s|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig
+const urlRegex = /(\s|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|$)/ig
/**
* @param {any} content -
diff --git a/lib/public/IURLGenerator.php b/lib/public/IURLGenerator.php
index f62503f14ec..0c7dc070778 100644
--- a/lib/public/IURLGenerator.php
+++ b/lib/public/IURLGenerator.php
@@ -51,7 +51,7 @@ interface IURLGenerator {
*
* @since 25.0.0
*/
- public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
+ public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)([-A-Z0-9+_.]+(?::[0-9]+)?(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
/**
* Returns the URL for a route