Skip to content

Commit d1c1c2f

Browse files
test(jsignpdf): add regression for zero-dimension stored config
Add data-provider entry with signatureWidth=0 and signatureHeight=0 that previously reached Imagick::newImage(0,0) causing the 'no pixels defined in cache' crash. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent c8bad6f commit d1c1c2f

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/php/Unit/Handler/SignEngine/JSignPdfHandlerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ public function testSignAffectedParams(
289289
$paramsAsOptions = preg_replace('/\\/\S+_text_image.png/', 'text_image.png', (string)$paramsAsOptions);
290290
$paramsAsOptions = preg_replace('/\\/\S+_background.png/', 'background.png', (string)$paramsAsOptions);
291291
$paramsAsOptions = preg_replace('/\\/\S+app-dark.png/', 'signature.png', (string)$paramsAsOptions);
292+
$paramsAsOptions = preg_replace('/ --tsa-server-url\s+\S+/', '', (string)$paramsAsOptions);
292293
$this->assertEquals($params, $paramsAsOptions);
293294
}
294295

@@ -507,6 +508,24 @@ public static function providerSignAffectedParams(): array {
507508
'hashAlgorithm' => '',
508509
'params' => '-a -kst PKCS12 --hash-algorithm SHA256 --l2-text "" -V -pg 2 -llx 10 -lly 20 -urx 30 -ury 40 --bg-path merged.png'
509510
],
511+
'regression: invalid stored dimensions should fallback to defaults and keep signing flow' => [
512+
'visibleElements' => [self::getElement([
513+
'page' => 2,
514+
'llx' => 10,
515+
'lly' => 20,
516+
'urx' => 30,
517+
'ury' => 40,
518+
], realpath(__DIR__ . '/../../../../../img/app-dark.png'))],
519+
'signatureWidth' => 0,
520+
'signatureHeight' => 0,
521+
'template' => '',
522+
'signatureBackgroundType' => 'default',
523+
'renderMode' => SignerElementsService::RENDER_MODE_GRAPHIC_AND_DESCRIPTION,
524+
'templateFontSize' => 10,
525+
'pdfContent' => '%PDF-1.6',
526+
'hashAlgorithm' => '',
527+
'params' => '-a -kst PKCS12 --hash-algorithm SHA256 --l2-text "" -V -pg 2 -llx 10 -lly 20 -urx 30 -ury 40 --bg-path merged.png'
528+
],
510529
];
511530
}
512531

0 commit comments

Comments
 (0)