Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c655f50
feat: integrate pdf-signature-validator for native validation
vitormattos Apr 23, 2026
bfbe5b3
refactor: translate signature validation messages via l10n
vitormattos Apr 24, 2026
0e98531
refactor: avoid translating dynamic reason strings
vitormattos Apr 24, 2026
28feed2
feat: add translatable dictionary for validation reasons
vitormattos Apr 24, 2026
298d9a0
docs: add translator guidance for validation reasons
vitormattos Apr 24, 2026
d688e1d
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
e8acf89
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
a75d0d1
refactor: remove redundant docs from CA getters
vitormattos Apr 24, 2026
40487ef
refactor: remove redundant comments in validation service
vitormattos Apr 24, 2026
1280298
test: remove deprecated reflection accessibility calls
vitormattos Apr 24, 2026
ef4c0f9
build: use released pdf-signature-validator v0.2.0
vitormattos Apr 24, 2026
f3525b1
refactor: centralize validation localization mapping
vitormattos Apr 24, 2026
295c103
fix: remove invalid UNKNOWN_FAILURE enum state
vitormattos Apr 24, 2026
2af043d
refactor: remove redundant localize* methods
vitormattos Apr 24, 2026
cc69a28
fix: cs
vitormattos Apr 24, 2026
c136b4b
fix: resolve Psalm type hint errors
vitormattos Apr 24, 2026
4530568
fix: update PasswordTest constructor arguments for Pkcs12Handler
vitormattos Apr 24, 2026
bdcf161
fix: cs
vitormattos Apr 24, 2026
ed285ef
fix: preserve legacy signature validation on native digest mismatch
vitormattos Apr 24, 2026
a661d5c
fix: address native validator review feedback
vitormattos Apr 24, 2026
681114b
fix: cs
vitormattos Apr 24, 2026
15712b6
fix: remove phpseclib from direct deps, use provide via 3rdparty
vitormattos Jun 18, 2026
149949b
refactor: move pdf-signature-validator to 3rdparty scoped vendor
vitormattos Jun 18, 2026
02d382a
fix(cs): fix use statement ordering per php-cs-fixer
vitormattos Jun 18, 2026
af67f5d
fix: propagate unexpected native validation exceptions
vitormattos Jul 7, 2026
240a55b
fix: always reset policy context on metadata failures
vitormattos Jul 7, 2026
55e7be1
test: cover native validation exception flow
vitormattos Jul 7, 2026
5b6afa6
test: cover metadata extraction failure propagation
vitormattos Jul 7, 2026
946c40e
fix: cs
vitormattos Jul 7, 2026
9adbf9d
fix: unit tests
vitormattos Jul 7, 2026
fe2615c
fix(sign-engine): backport policy validation context
vitormattos Jul 7, 2026
9278ca8
fix(sign-engine): restore native validation flow
vitormattos Jul 7, 2026
ae0c89a
test(sign-engine): cover stable native validation flow
vitormattos Jul 7, 2026
a625468
Revert "fix(sign-engine): backport policy validation context"
vitormattos Jul 7, 2026
a5ddfe8
fix(backport): drop policy context from stable34
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 @@ -457,14 +457,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 @@ -483,19 +492,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