Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e9ec33c
feat: integrate pdf-signature-validator for native validation
vitormattos Apr 23, 2026
e909434
refactor: translate signature validation messages via l10n
vitormattos Apr 24, 2026
0411b53
refactor: avoid translating dynamic reason strings
vitormattos Apr 24, 2026
205c651
feat: add translatable dictionary for validation reasons
vitormattos Apr 24, 2026
9ecd562
docs: add translator guidance for validation reasons
vitormattos Apr 24, 2026
d9a66a5
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
a7ed09b
docs: place translator comments above each l10n call
vitormattos Apr 24, 2026
1cb5b06
refactor: remove redundant docs from CA getters
vitormattos Apr 24, 2026
2b2bf21
refactor: remove redundant comments in validation service
vitormattos Apr 24, 2026
61bf6f0
test: remove deprecated reflection accessibility calls
vitormattos Apr 24, 2026
7a3ae4c
build: use released pdf-signature-validator v0.2.0
vitormattos Apr 24, 2026
3444d8f
refactor: centralize validation localization mapping
vitormattos Apr 24, 2026
7395843
fix: remove invalid UNKNOWN_FAILURE enum state
vitormattos Apr 24, 2026
df3cd62
refactor: remove redundant localize* methods
vitormattos Apr 24, 2026
a5c2db3
fix: cs
vitormattos Apr 24, 2026
6bc699c
fix: resolve Psalm type hint errors
vitormattos Apr 24, 2026
599e5c2
fix: update PasswordTest constructor arguments for Pkcs12Handler
vitormattos Apr 24, 2026
154d90d
fix: cs
vitormattos Apr 24, 2026
d7b4588
fix: preserve legacy signature validation on native digest mismatch
vitormattos Apr 24, 2026
43dc4a0
fix: address native validator review feedback
vitormattos Apr 24, 2026
6015855
fix: cs
vitormattos Apr 24, 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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"require": {
"cweagans/composer-patches": "^2.0",
"jeidison/signer-php": "^1.0",
"libresign/pdf-signature-validator": "^0.2.0",
"phpseclib/phpseclib": "^3.0"
}
}
53 changes: 52 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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