Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable25] Add a capability for the reference API and expose the regex to clients #34413

Merged
merged 1 commit into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/private/OCS/CoreCapabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use OCP\Capabilities\ICapability;
use OCP\IConfig;
use OCP\IURLGenerator;

/**
* Class Capabilities
Expand Down Expand Up @@ -52,7 +53,9 @@ public function getCapabilities() {
'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,
],
];
}
}
11 changes: 10 additions & 1 deletion lib/public/IURLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down