Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
602c221
feat: integrate pdf-signature-validator for native validation
vitormattos Apr 23, 2026
58718e8
refactor: translate signature validation messages via l10n
vitormattos Apr 24, 2026
4e6236f
refactor: avoid translating dynamic reason strings
vitormattos Apr 24, 2026
a37d8e3
feat: add translatable dictionary for validation reasons
vitormattos Apr 24, 2026
1213947
docs: add translator guidance for validation reasons
vitormattos Apr 24, 2026
8723bce
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
3dafc5b
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
4751b24
refactor: remove redundant docs from CA getters
vitormattos Apr 24, 2026
6f3970f
refactor: remove redundant comments in validation service
vitormattos Apr 24, 2026
adaadf7
test: remove deprecated reflection accessibility calls
vitormattos Apr 24, 2026
0129528
build: use released pdf-signature-validator v0.2.0
vitormattos Apr 24, 2026
0dff429
refactor: centralize validation localization mapping
vitormattos Apr 24, 2026
f45ff2b
fix: remove invalid UNKNOWN_FAILURE enum state
vitormattos Apr 24, 2026
18a10a9
refactor: remove redundant localize* methods
vitormattos Apr 24, 2026
bebc11e
fix: cs
vitormattos Apr 24, 2026
8a078af
fix: resolve Psalm type hint errors
vitormattos Apr 24, 2026
8f8195d
fix: update PasswordTest constructor arguments for Pkcs12Handler
vitormattos Apr 24, 2026
739ec4a
fix: cs
vitormattos Apr 24, 2026
7ea10ee
fix: preserve legacy signature validation on native digest mismatch
vitormattos Apr 24, 2026
6ba971e
fix: address native validator review feedback
vitormattos Apr 24, 2026
361675d
fix: cs
vitormattos Apr 24, 2026
aaa6617
fix: remove phpseclib from direct deps, use provide via 3rdparty
vitormattos Jun 18, 2026
04ba730
refactor: move pdf-signature-validator to 3rdparty scoped vendor
vitormattos Jun 18, 2026
e9b887a
fix(cs): fix use statement ordering per php-cs-fixer
vitormattos Jun 18, 2026
ad89ce5
fix: propagate unexpected native validation exceptions
vitormattos Jul 7, 2026
f31f34f
fix: always reset policy context on metadata failures
vitormattos Jul 7, 2026
39192a0
test: cover native validation exception flow
vitormattos Jul 7, 2026
adcb25d
test: cover metadata extraction failure propagation
vitormattos Jul 7, 2026
3574b2b
fix: cs
vitormattos Jul 7, 2026
8c9f943
fix: unit tests
vitormattos Jul 7, 2026
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
45 changes: 39 additions & 6 deletions lib/Controller/FileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,23 @@ private function fetchPreview(
bool $forceIcon,
string $mode,
bool $mimeFallback = false,
) : Http\Response {
): Http\Response {
if (!($node instanceof File) || (!$forceIcon && !$this->preview->isAvailable($node))) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
if (!$node->isReadable()) {
return new DataResponse([], Http::STATUS_FORBIDDEN);
}

// Avoid expensive external preview generators for PDFs when a mime fallback is explicitly requested.
if ($mimeFallback && $node->getMimeType() === 'application/pdf') {
$mimeFallbackResponse = $this->getMimeFallbackResponse($node->getMimeType());
if ($mimeFallbackResponse !== null) {
/** @var Http\RedirectResponse<Http::STATUS_SEE_OTHER, array{}> $mimeFallbackResponse */
return $mimeFallbackResponse;
}
}

$storage = $node->getStorage();
if ($storage->instanceOfStorage(SharedStorage::class)) {
/** @var SharedStorage $storage */
Expand All @@ -505,19 +514,43 @@ private function fetchPreview(
$response->cacheFor(3600 * 24, false, true);
return $response;
} catch (NotFoundException) {
// If we have no preview enabled, we can redirect to the mime icon if any
if ($mimeFallback) {
if ($url = $this->mimeIconProvider->getMimeIconUrl($node->getMimeType())) {
return new RedirectResponse($url);
}
$mimeFallbackResponse = $mimeFallback ? $this->getMimeFallbackResponse($node->getMimeType()) : null;
if ($mimeFallbackResponse !== null) {
/** @var Http\RedirectResponse<Http::STATUS_SEE_OTHER, array{}> $mimeFallbackResponse */
return $mimeFallbackResponse;
}

return new DataResponse([], Http::STATUS_NOT_FOUND);
} catch (\InvalidArgumentException) {
return new DataResponse([], Http::STATUS_BAD_REQUEST);
} catch (\Throwable $e) {
$this->logger->warning('Failed to generate LibreSign thumbnail preview', [
'nodeId' => $node->getId(),
'mimeType' => $node->getMimeType(),
'exception' => $e,
]);

$mimeFallbackResponse = $mimeFallback ? $this->getMimeFallbackResponse($node->getMimeType()) : null;
if ($mimeFallbackResponse !== null) {
/** @var Http\RedirectResponse<Http::STATUS_SEE_OTHER, array{}> $mimeFallbackResponse */
return $mimeFallbackResponse;
}

return new DataResponse([], Http::STATUS_NOT_FOUND);
}
}

private function getMimeFallbackResponse(string $mimeType): ?\OCP\AppFramework\Http\RedirectResponse {
$url = $this->mimeIconProvider->getMimeIconUrl($mimeType);
if ($url) {
/** @var \OCP\AppFramework\Http\RedirectResponse<Http::STATUS_SEE_OTHER, array{}> $response */
$response = new RedirectResponse($url, Http::STATUS_SEE_OTHER);
return $response;
}

return null;
}

/**
* Send a file
*
Expand Down
Loading
Loading