diff options
author | Julius Härtl <jus@bitgrid.net> | 2022-08-28 20:54:21 +0200 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2022-08-31 16:24:33 +0200 |
commit | a392235e23c3b8af1d0eba4dbac18b18de826a1c (patch) | |
tree | c983c213d99937bb53463e759d703d85861fb631 /core | |
parent | bee8fd2408b053756e052a2b96899935c1adf872 (diff) | |
download | nextcloud-server-a392235e23c3b8af1d0eba4dbac18b18de826a1c.tar.gz nextcloud-server-a392235e23c3b8af1d0eba4dbac18b18de826a1c.zip |
Cleanup
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'core')
-rw-r--r-- | core/Controller/ReferenceApiController.php | 19 | ||||
-rw-r--r-- | core/Controller/ReferenceController.php | 19 | ||||
-rw-r--r-- | core/src/OCP/comments.js | 2 |
3 files changed, 20 insertions, 20 deletions
diff --git a/core/Controller/ReferenceApiController.php b/core/Controller/ReferenceApiController.php index d9af5520cfc..3e94bf34c25 100644 --- a/core/Controller/ReferenceApiController.php +++ b/core/Controller/ReferenceApiController.php @@ -25,23 +25,19 @@ declare(strict_types=1); namespace OC\Core\Controller; use OCP\AppFramework\Http\DataResponse; -use OC\Collaboration\Reference\ReferenceManager; +use OCP\Collaboration\Reference\IReferenceManager; use OCP\IRequest; class ReferenceApiController extends \OCP\AppFramework\OCSController { - private ReferenceManager $referenceManager; + private IReferenceManager $referenceManager; - public function __construct($appName, IRequest $request, ReferenceManager $referenceManager) { + public function __construct(string $appName, IRequest $request, IReferenceManager $referenceManager) { parent::__construct($appName, $request); $this->referenceManager = $referenceManager; } /** * @NoAdminRequired - * - * @param string $text - * @param bool $resolve - * @return DataResponse */ public function extract(string $text, bool $resolve = false, int $limit = 1): DataResponse { $references = $this->referenceManager->extractReferences($text); @@ -63,16 +59,17 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { /** * @NoAdminRequired * - * @param array $references - * @return DataResponse + * @param string[] $references */ public function resolve(array $references, int $limit = 1): DataResponse { $result = []; $index = 0; foreach ($references as $reference) { - if ($index++ < $limit) { - $result[$reference] = $this->referenceManager->resolveReference($reference); + if ($index++ >= $limit) { + break; } + + $result[$reference] = $this->referenceManager->resolveReference($reference); } return new DataResponse([ diff --git a/core/Controller/ReferenceController.php b/core/Controller/ReferenceController.php index dda213db54d..93510a35f4a 100644 --- a/core/Controller/ReferenceController.php +++ b/core/Controller/ReferenceController.php @@ -24,18 +24,21 @@ declare(strict_types=1); namespace OC\Core\Controller; -use OC\Collaboration\Reference\ReferenceManager; +use OCP\Collaboration\Reference\IReferenceManager; +use OCP\AppFramework\Controller; use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataDownloadResponse; use OCP\AppFramework\Http\DataResponse; use OCP\Files\AppData\IAppDataFactory; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\IRequest; -class ReferenceController extends \OCP\AppFramework\Controller { - private ReferenceManager $referenceManager; +class ReferenceController extends Controller { + private IReferenceManager $referenceManager; + private IAppDataFactory $appDataFactory; - public function __construct($appName, IRequest $request, ReferenceManager $referenceManager, IAppDataFactory $appDataFactory) { + public function __construct(string $appName, IRequest $request, IReferenceManager $referenceManager, IAppDataFactory $appDataFactory) { parent::__construct($appName, $request); $this->referenceManager = $referenceManager; $this->appDataFactory = $appDataFactory; @@ -44,10 +47,8 @@ class ReferenceController extends \OCP\AppFramework\Controller { /** * @PublicPage * @NoCSRFRequired - * @param $referenceId - * @throws \OCP\Files\NotFoundException */ - public function preview($referenceId) { + public function preview(string $referenceId) { $reference = $this->referenceManager->getReferenceByCacheKey($referenceId); if ($reference === null) { return new DataResponse('', Http::STATUS_NOT_FOUND); @@ -57,9 +58,9 @@ class ReferenceController extends \OCP\AppFramework\Controller { $appData = $this->appDataFactory->get('core'); $folder = $appData->getFolder('opengraph'); $file = $folder->getFile($referenceId); - } catch (NotFoundException $e) { + return new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType()); + } catch (NotFoundException|NotPermittedException $e) { return new DataResponse('', Http::STATUS_NOT_FOUND); } - return new DataDownloadResponse($file->getContent(), $referenceId, $reference->getImageContentType()); } } diff --git a/core/src/OCP/comments.js b/core/src/OCP/comments.js index ed7ac67a073..0b44dd7be81 100644 --- a/core/src/OCP/comments.js +++ b/core/src/OCP/comments.js @@ -31,6 +31,8 @@ import $ from 'jquery' * * The downside: anything not ascii is excluded. Not sure how common it is in areas using different * alphabets… the upside: fake domains with similar looking characters won't be formatted as links + * + * 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 |