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
048249e
feat: integrate pdf-signature-validator for native validation
vitormattos Apr 23, 2026
9db2e63
refactor: translate signature validation messages via l10n
vitormattos Apr 24, 2026
9d4686b
refactor: avoid translating dynamic reason strings
vitormattos Apr 24, 2026
38623a6
feat: add translatable dictionary for validation reasons
vitormattos Apr 24, 2026
b9796c6
docs: add translator guidance for validation reasons
vitormattos Apr 24, 2026
dcd2ab5
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
dd098b6
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
7bc2873
refactor: remove redundant docs from CA getters
vitormattos Apr 24, 2026
f269442
refactor: remove redundant comments in validation service
vitormattos Apr 24, 2026
8355371
test: remove deprecated reflection accessibility calls
vitormattos Apr 24, 2026
f5e5a4a
build: use released pdf-signature-validator v0.2.0
vitormattos Apr 24, 2026
135a11c
refactor: centralize validation localization mapping
vitormattos Apr 24, 2026
0c1a65d
fix: remove invalid UNKNOWN_FAILURE enum state
vitormattos Apr 24, 2026
e7e86a3
refactor: remove redundant localize* methods
vitormattos Apr 24, 2026
9ceba01
fix: cs
vitormattos Apr 24, 2026
79f25fc
fix: resolve Psalm type hint errors
vitormattos Apr 24, 2026
ff5261d
fix: update PasswordTest constructor arguments for Pkcs12Handler
vitormattos Apr 24, 2026
f65fc6c
fix: cs
vitormattos Apr 24, 2026
1b3a5d3
fix: preserve legacy signature validation on native digest mismatch
vitormattos Apr 24, 2026
0121ba4
fix: address native validator review feedback
vitormattos Apr 24, 2026
72b7126
fix: cs
vitormattos Apr 24, 2026
72e0c8f
fix: remove phpseclib from direct deps, use provide via 3rdparty
vitormattos Jun 18, 2026
b46a2f2
refactor: move pdf-signature-validator to 3rdparty scoped vendor
vitormattos Jun 18, 2026
acaccfd
fix(cs): fix use statement ordering per php-cs-fixer
vitormattos Jun 18, 2026
7cc2f0d
fix: propagate unexpected native validation exceptions
vitormattos Jul 7, 2026
84d7a69
fix: always reset policy context on metadata failures
vitormattos Jul 7, 2026
7cb6ab1
test: cover native validation exception flow
vitormattos Jul 7, 2026
0c9ffc0
test: cover metadata extraction failure propagation
vitormattos Jul 7, 2026
0d7674a
fix: cs
vitormattos Jul 7, 2026
48732b0
fix: unit tests
vitormattos Jul 7, 2026
369487d
fix(sign-engine): backport policy validation context
vitormattos Jul 7, 2026
bf65c5d
fix(sign-engine): restore native validation flow
vitormattos Jul 7, 2026
f844a3c
test(sign-engine): cover stable native validation flow
vitormattos Jul 7, 2026
f9b096f
Revert "fix(sign-engine): backport policy validation context"
vitormattos Jul 7, 2026
d6c68ac
fix(backport): drop policy context from stable33
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