You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(signature-text): reject invalid dimensions at save and auto-repair on read
At save: reject signatureWidth or signatureHeight that are non-finite
(NaN, Inf, -Inf) or below SIGNATURE_DIMENSION_MINIMUM (1). The guard
uses is_finite() before the range check because PHP NaN comparisons
always return false, silently letting NaN through.
At read: getSanitizedDimension() replaces getValueFloat() calls in
getFullSignatureWidth() and getFullSignatureHeight(). If the stored
value is non-finite or below the minimum it writes back the default,
logs a warning, and returns the default — preventing Imagick from
receiving a zero or invalid canvas size.
Fixes: Imagick exception 'no pixels defined in cache' triggered when
the app config contains a corrupted or zero dimension value.
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Copy file name to clipboardExpand all lines: lib/Service/SignatureTextService.php
+31-3Lines changed: 31 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,7 @@
29
29
class SignatureTextService {
30
30
publicconstTEMPLATE_DEFAULT_FONT_SIZE = 10;
31
31
publicconstSIGNATURE_DEFAULT_FONT_SIZE = 20;
32
+
publicconstSIGNATURE_DIMENSION_MINIMUM = 1;
32
33
publicconstFONT_SIZE_MINIMUM = 0.1;
33
34
publicconstFRONT_SIZE_MAX = 30;
34
35
publicconstDEFAULT_SIGNATURE_WIDTH = 350;
@@ -69,6 +70,19 @@ public function save(
69
70
// within the accepted range.
70
71
thrownewLibresignException($this->l10n->t('Invalid signature font size. The value must be between %.1f and %.0f.', [self::FONT_SIZE_MINIMUM, self::FRONT_SIZE_MAX]));
// TRANSLATORS This message is shown when the visible signature box size
80
+
// configured by the admin is invalid. "Signature box" is the rectangular
81
+
// area reserved for the handwritten-style signature image in the signed
82
+
// PDF. "Width" and "height" are its pixel dimensions. %.0f is the
83
+
// minimum allowed value for each dimension.
84
+
thrownewLibresignException($this->l10n->t('Invalid signature box size. Width and height must be at least %.0f.', [self::SIGNATURE_DIMENSION_MINIMUM]));
85
+
}
72
86
$template = trim($template);
73
87
$template = preg_replace(
74
88
[
@@ -432,11 +446,11 @@ public function getDefaultTemplate(): string {
0 commit comments