summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Collaboration/Reference/LinkReferenceProvider.php16
-rw-r--r--lib/private/legacy/OC_Helper.php6
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/private/Collaboration/Reference/LinkReferenceProvider.php b/lib/private/Collaboration/Reference/LinkReferenceProvider.php
index 5597df1ca97..583cbdcfe99 100644
--- a/lib/private/Collaboration/Reference/LinkReferenceProvider.php
+++ b/lib/private/Collaboration/Reference/LinkReferenceProvider.php
@@ -105,6 +105,22 @@ class LinkReferenceProvider implements IReferenceProvider {
$client = $this->clientService->newClient();
try {
+ $headResponse = $client->head($reference->getId(), [ 'timeout' => 10 ]);
+ } catch (\Exception $e) {
+ $this->logger->debug('Failed to perform HEAD request to get target metadata', ['exception' => $e]);
+ return;
+ }
+ $linkContentLength = $headResponse->getHeader('Content-Length');
+ if (is_numeric($linkContentLength) && (int) $linkContentLength > 5 * 1024 * 1024) {
+ $this->logger->debug('Skip resolving links pointing to content length > 5 MB');
+ return;
+ }
+ $linkContentType = $headResponse->getHeader('Content-Type');
+ if ($linkContentType !== 'text/html') {
+ $this->logger->debug('Skip resolving links pointing to content type that is not "text/html"');
+ return;
+ }
+ try {
$response = $client->get($reference->getId(), [ 'timeout' => 10 ]);
} catch (\Exception $e) {
$this->logger->debug('Failed to fetch link for obtaining open graph data', ['exception' => $e]);
diff --git a/lib/private/legacy/OC_Helper.php b/lib/private/legacy/OC_Helper.php
index de42a7bc7fc..5ee6ec69ac2 100644
--- a/lib/private/legacy/OC_Helper.php
+++ b/lib/private/legacy/OC_Helper.php
@@ -547,10 +547,10 @@ class OC_Helper {
$ownerId = $storage->getOwner($path);
$ownerDisplayName = '';
- $owner = \OC::$server->getUserManager()->get($ownerId);
- if ($owner) {
- $ownerDisplayName = $owner->getDisplayName();
+ if ($ownerId) {
+ $ownerDisplayName = \OC::$server->getUserManager()->getDisplayName($ownerId) ?? '';
}
+
if (substr_count($mount->getMountPoint(), '/') < 3) {
$mountPoint = '';
} else {