Skip to content

fix: support Twig date filter for ServerSignatureDate in JSign#7644

Merged
vitormattos merged 2 commits intomainfrom
fix/7619-server-signature-date-twig
May 6, 2026
Merged

fix: support Twig date filter for ServerSignatureDate in JSign#7644
vitormattos merged 2 commits intomainfrom
fix/7619-server-signature-date-twig

Conversation

@vitormattos
Copy link
Copy Markdown
Member

@vitormattos vitormattos commented May 6, 2026

Summary

Fixes signing failures when ServerSignatureDate is transformed in Twig templates (for example |date("d/m/Y H:i:s T", "Europe/Paris")) while preserving the existing ${timestamp} behavior for plain templates.

What changed

  • JSignPdfHandler::parseSignatureText() now chooses the source of ServerSignatureDate based on template usage:
    • keeps ${timestamp} when template uses plain {{ServerSignatureDate}}
    • uses real ISO timestamp when template applies Twig transformations (e.g. filters)
  • Added regression test for Twig date filter with timezone.
  • Added compatibility assertion ensuring plain {{ServerSignatureDate}} still renders to JSign placeholder (${timestamp}).

Why

Issue #7619 reproduces only during signing because JSign path previously fed ${timestamp} into Twig parsing. This works for plain interpolation but breaks when Twig tries to format it as a date.

Validation

  • composer test:unit -- --filter "JSignPdfHandlerTest::testGetSignatureText"
  • composer test:unit -- --filter "JSignPdfHandlerTest::testGetSignatureTextWithTwigDateFilterAndTimezone"

Ref #7619

Keep ${timestamp} for plain {{ServerSignatureDate}} templates so JSign can inject its signing timestamp, but provide an ISO date when the template transforms the value (for example with Twig date filters).

Add regression coverage for Twig date filter with timezone and keep compatibility assertion for the plain placeholder case.

Fixes #7619

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in Roadmap May 6, 2026
PhpNativeHandler was setting ServerSignatureDate to a custom
'Y.m.d H:i:s UTC' string while JSignPdfHandler (after the prior
fix) and the preview context (SignatureTextService::parse) both
use DateTimeInterface::ATOM. This inconsistency could cause the
Twig |date() filter to fail or produce unexpected results in
PhpNativeHandler-signed documents.

Changes:
- PhpNativeHandler: use DateTimeImmutable::ATOM for ServerSignatureDate
- SignatureTextService::getAvailableVariables(): correct the
  description to state the variable CAN be formatted with Twig
- JSignPdfHandlerTest: add cases for {{ ServerSignatureDate }}
  with spaces, |date() without timezone, and GRAPHIC_ONLY +
  date filter
- PhpNativeHandlerTest: assert ServerSignatureDate is valid
  ISO 8601 / ATOM when passed to signatureTextService->parse()

Closes #7619

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
Copy link
Copy Markdown
Member Author

/backport to stable33

@vitormattos
Copy link
Copy Markdown
Member Author

/backport to stable32

@vitormattos vitormattos merged commit b9f0087 into main May 6, 2026
77 checks passed
@vitormattos vitormattos deleted the fix/7619-server-signature-date-twig branch May 6, 2026 13:42
@github-project-automation github-project-automation Bot moved this from 0. Needs triage to 4. to release in Roadmap May 6, 2026
vitormattos added a commit that referenced this pull request May 6, 2026
Add PhpNativeHandler and PhpNativeHandlerTest from upstream PR #7644 to keep backport parity for ServerSignatureDate ATOM formatting coverage.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 4. to release

Development

Successfully merging this pull request may close these issues.

1 participant