Skip to content

Commit 3b1eac5

Browse files
committed
fix(JSignPdfHandler): guard mergeBackgroundWithSignature against empty image path
When background is present but the signer submitted no image (clickToSign), passing an empty string to mergeBackgroundWithSignature caused new Imagick('') to throw. Guard the call: only merge when both paths are non-empty; fall back to background-only or signature-only as appropriate. Also skip --img-path entirely when signatureImagePath is empty in GRAPHIC_AND_DESCRIPTION mode. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 5dd8dd2 commit 3b1eac5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/Handler/SignEngine/JSignPdfHandler.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,20 +366,24 @@ private function signUsingVisibleElements(string $normalizedPdf, string $hashAlg
366366
$params['--bg-path'] = $signatureImagePath;
367367
}
368368
} elseif ($params['--l2-text'] === '""') {
369-
if ($backgroundPathForElement) {
369+
if ($backgroundPathForElement && $signatureImagePath) {
370370
$params['--bg-path'] = $this->mergeBackgroundWithSignature(
371371
$backgroundPathForElement,
372372
$signatureImagePath,
373373
$this->normalizeScaleFactor($scaleFactor),
374374
);
375-
} else {
375+
} elseif ($backgroundPathForElement) {
376+
$params['--bg-path'] = $backgroundPathForElement;
377+
} elseif ($signatureImagePath) {
376378
$params['--bg-path'] = $signatureImagePath;
377379
}
378380
} else {
379381
if ($renderMode === SignerElementsService::RENDER_MODE_GRAPHIC_AND_DESCRIPTION) {
380382
$params['--render-mode'] = SignerElementsService::RENDER_MODE_GRAPHIC_AND_DESCRIPTION;
381383
$params['--bg-path'] = $backgroundPathForElement;
382-
$params['--img-path'] = $signatureImagePath;
384+
if ($signatureImagePath) {
385+
$params['--img-path'] = $signatureImagePath;
386+
}
383387
} elseif ($renderMode === SignerElementsService::RENDER_MODE_SIGNAME_AND_DESCRIPTION) {
384388
$params['--render-mode'] = SignerElementsService::RENDER_MODE_GRAPHIC_AND_DESCRIPTION;
385389
$params['--bg-path'] = $backgroundPathForElement;

0 commit comments

Comments
 (0)