Skip to content

Commit

Permalink
Merge pull request #374 from strukturag/shorter-filename
Browse files Browse the repository at this point in the history
Use shorter filename if too long with signer name.
  • Loading branch information
fancycode committed May 29, 2024
2 parents 5e25cd5 + 7318837 commit d3a72b9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
use Psr\Log\LoggerInterface;

class Manager {
// Maximum length of a filename to support saving on Windows.
public const MAX_FILENAME_LENGTH = 255;

private LoggerInterface $logger;
private IEventDispatcher $dispatcher;
private IConfig $systemConfig;
Expand Down Expand Up @@ -177,6 +180,12 @@ private function storeSignedResult(?IUser $user, array $row, \DateTime $signed,
$signerName,
$this->formatter->formatDateTime($signed, 'long', 'medium', $timeZone, $l10n),
]) . ($info['extension'] ? ('.' . $info['extension']) : '');
if (strlen($filename) >= self::MAX_FILENAME_LENGTH) {
$filename = $l10n->t('%1$s signed on %2$s', [
$info['filename'],
$this->formatter->formatDateTime($signed, 'long', 'medium', $timeZone, $l10n),
]) . ($info['extension'] ? ('.' . $info['extension']) : '');
}
} else {
$filename = $l10n->t('%1$s signed on %2$s', [
$info['filename'],
Expand Down

0 comments on commit d3a72b9

Please sign in to comment.