Skip to content
Merged
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
16 changes: 16 additions & 0 deletions lib/private/Collaboration/Reference/LinkReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,22 @@ private function fetchReference(Reference $reference): void {
}

$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) {
Expand Down