• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LibreSign / libresign / 20048275241

09 Dec 2025 01:05AM UTC coverage: 44.16%. First build
20048275241

Pull #6035

github

web-flow
Merge 27bf7283d into 2abe0feb0
Pull Request #6035: fix: prevent footer on signed pdfs

12 of 19 new or added lines in 2 files covered. (63.16%)

5690 of 12885 relevant lines covered (44.16%)

5.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/Service/PdfSignatureDetectionService.php
1
<?php
2

3
declare(strict_types=1);
4
/**
5
 * SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8

9
namespace OCA\Libresign\Service;
10

11
use OCA\Libresign\Handler\SignEngine\SignEngineFactory;
12
use Psr\Log\LoggerInterface;
13

14
class PdfSignatureDetectionService {
15
        public function __construct(
16
                private SignEngineFactory $signEngineFactory,
17
                private LoggerInterface $logger,
18
        ) {
19
        }
53✔
20

21
        /**
22
         * Check if a PDF has existing signatures
23
         *
24
         * @param string $pdfContent The PDF file content
25
         * @return bool True if the file has signatures, false otherwise
26
         */
27
        public function hasSignatures(string $pdfContent): bool {
28
                $resource = fopen('php://memory', 'r+');
6✔
29
                if ($resource === false) {
6✔
NEW
30
                        $this->logger->warning('Failed to create resource for signature detection');
×
NEW
31
                        return false;
×
32
                }
33

34
                fwrite($resource, $pdfContent);
6✔
35
                rewind($resource);
6✔
36

37
                try {
38
                        $engine = $this->signEngineFactory->resolve('pdf');
6✔
39
                        $certificates = $engine->getCertificateChain($resource);
6✔
40
                        return !empty($certificates);
3✔
41
                } catch (\Throwable $e) {
3✔
42
                        $this->logger->debug('Failed to detect signatures: ' . $e->getMessage());
3✔
43
                        return false;
3✔
44
                } finally {
45
                        fclose($resource);
6✔
46
                }
47
        }
48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc