diff --git a/lib/Handler/FooterHandler.php b/lib/Handler/FooterHandler.php index 78b93d1e0..962c3188c 100644 --- a/lib/Handler/FooterHandler.php +++ b/lib/Handler/FooterHandler.php @@ -108,11 +108,7 @@ public function setTemplateVar(string $name, mixed $value): self { } private function getTemplateVars(): array { - $this->templateVars['signedBy'] = iconv( - 'UTF-8', - 'windows-1252', - $this->appConfig->getValueString(Application::APP_ID, 'footer_signed_by', $this->l10n->t('Digital signed by LibreSign.')) - ); + $this->templateVars['signedBy'] = $this->appConfig->getValueString(Application::APP_ID, 'footer_signed_by', $this->l10n->t('Digital signed by LibreSign.')); $this->templateVars['linkToSite'] = $this->appConfig->getValueString(Application::APP_ID, 'footer_link_to_site', 'https://libresign.coop'); @@ -130,6 +126,10 @@ private function getTemplateVars(): array { $this->templateVars['validateIn'] = $this->l10n->t('Validate in %s.', ['%s']); } + foreach ($this->templateVars as $key => $value) { + $this->templateVars[$key] = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); + } + if ($this->appConfig->getValueBool(Application::APP_ID, 'write_qrcode_on_footer', true)) { $this->templateVars['qrcode'] = $this->getQrCodeImageBase64($this->templateVars['validationSite']); } diff --git a/tests/Unit/Handler/FooterHandlerTest.php b/tests/Unit/Handler/FooterHandlerTest.php index 3571baded..d910552ea 100644 --- a/tests/Unit/Handler/FooterHandlerTest.php +++ b/tests/Unit/Handler/FooterHandlerTest.php @@ -86,7 +86,6 @@ public function testGetFooterWithSuccess(array $settings, array $expected): void }; }); $pdf = $this->getClass() - ->setTemplateVar('test', 'fake value') ->getFooter($file, $libresignFile); if ($settings['add_footer']) { $actual = $this->extractPdfContent($pdf, array_keys($expected)); @@ -118,7 +117,6 @@ public static function dataGetFooterWithSuccess(): array { qrcodeSize:
signedBy:
validateIn:
- test:
qrcode: HTML, @@ -128,7 +126,6 @@ public static function dataGetFooterWithSuccess(): array { 'qrcodeSize' => '108', 'signedBy' => 'Digital signed by LibreSign.', 'validateIn' => 'Validate in %s.', - 'test' => 'fake value', ] ], [ @@ -143,16 +140,54 @@ public static function dataGetFooterWithSuccess(): array {
signedBy:
validateIn:
- test:
HTML, ], [ 'signedBy' => 'Digital signed by LibreSign.', 'validateIn' => 'Validate in %s.', - 'test' => 'fake value', ] - ] + ], + [ + [ + 'add_footer' => true, + 'validation_site' => 'http://test.coop', + 'write_qrcode_on_footer' => false, + 'footer_link_to_site' => 'https://libresign.coop', + 'footer_signed_by' => 'Signé numériquement avec LibreSign.', + 'footer_validate_in' => 'Validate in %s', + 'footer_template' => <<<'HTML' +
+ signedBy:
+ validateIn:
+
+ HTML, + ], + [ + 'signedBy' => 'Signé numériquement avec LibreSign.', + 'validateIn' => 'Validate in %s', + ] + ], + [ + [ + 'add_footer' => true, + 'validation_site' => 'http://test.coop', + 'write_qrcode_on_footer' => false, + 'footer_link_to_site' => 'https://libresign.coop', + 'footer_signed_by' => 'Το αρχείο υπάρχει', + 'footer_validate_in' => 'Validate in %s.', + 'footer_template' => <<<'HTML' +
+ signedBy:
+ validateIn:
+
+ HTML, + ], + [ + 'signedBy' => 'Το αρχείο υπάρχει', + 'validateIn' => 'Validate in %s.', + ] + ], ]; }