Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2022-10-03 19:23:21 +0300
committerGitHub <noreply@github.com>2022-10-03 19:23:21 +0300
commitf888f99b0a4f599ea403cdf337935093c5420586 (patch)
treea112c76282641ac1a02e8f2956a6d76f9e620d7f
parent586d031a530a39214ddf16c7f27b27c7a23dc584 (diff)
parentd434da75bb872e19c26839b5a73c022b1ba956e0 (diff)
Merge pull request #34350 from nextcloud/bugfix/34278/add-capability-for-the-reference-api
Add a capability for the reference API and expose the regex to clients
-rw-r--r--lib/private/OCS/CoreCapabilities.php5
-rw-r--r--lib/public/IURLGenerator.php11
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/private/OCS/CoreCapabilities.php b/lib/private/OCS/CoreCapabilities.php
index ab06b04cc91..578152ff108 100644
--- a/lib/private/OCS/CoreCapabilities.php
+++ b/lib/private/OCS/CoreCapabilities.php
@@ -24,6 +24,7 @@ namespace OC\OCS;
use OCP\Capabilities\ICapability;
use OCP\IConfig;
+use OCP\IURLGenerator;
/**
* Class Capabilities
@@ -52,7 +53,9 @@ class CoreCapabilities implements ICapability {
'core' => [
'pollinterval' => $this->config->getSystemValue('pollinterval', 60),
'webdav-root' => $this->config->getSystemValue('webdav-root', 'remote.php/webdav'),
- ]
+ 'reference-api' => true,
+ 'reference-regex' => IURLGenerator::URL_REGEX_NO_MODIFIERS,
+ ],
];
}
}
diff --git a/lib/public/IURLGenerator.php b/lib/public/IURLGenerator.php
index be0edf61025..b6d78876478 100644
--- a/lib/public/IURLGenerator.php
+++ b/lib/public/IURLGenerator.php
@@ -43,7 +43,16 @@ interface IURLGenerator {
*
* @since 25.0.0
*/
- public const URL_REGEX = '/(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)/mi';
+ public const URL_REGEX = '/' . self::URL_REGEX_NO_MODIFIERS . '/mi';
+
+ /**
+ * Regex for matching http(s) urls (without modifiers for client compatibility)
+ *
+ * This is a copy of the frontend regex in core/src/OCP/comments.js, make sure to adjust both when changing
+ *
+ * @since 25.0.0
+ */
+ public const URL_REGEX_NO_MODIFIERS = '(\s|\n|^)(https?:\/\/)((?:[-A-Z0-9+_]+\.)+[-A-Z]+(?:\/[-A-Z0-9+&@#%?=~_|!:,.;()]*)*)(\s|\n|$)';
/**
* Returns the URL for a route