]> _ Git - fluidbook-toolbox.git/commitdiff
wip #7871 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jan 2026 11:49:37 +0000 (12:49 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 7 Jan 2026 11:49:37 +0000 (12:49 +0100)
app/Http/Controllers/Admin/Operations/FluidbookPublication/Services/PDFFormOperation.php
app/Models/Traits/PublicationSettings.php

index 98acc4cc7f32dad44e7d2738b69f0444f4861c84..38d1b83a39269dc7d2f1640e5ef195124b7b187f 100644 (file)
@@ -39,18 +39,22 @@ trait PDFFormOperation
         $email = false;
 
         $tmp = Files::tempnam() . '.pdf';
+        $raw = '';
         $fdfFields = '%FDF-1.2
 1 0 obj<</FDF<< /Fields[' . "\n";
         foreach ($fields as $k => $v) {
+            $rawValue = $v;
             if (in_array($k, $emailFields)) {
                 $email = $v;
             }
             if (str_starts_with($v, ':checked:')) {
-                $val = 'V/' . utf8_decode(ucfirst(substr($v, 9)));
+                $rawValue = ucfirst(substr($v, 9));
+                $val = 'V/' . $this->_escapeFDF($rawValue);
             } else {
-                $val = 'V(' . utf8_decode($v) . ')';
+                $val = 'V(' . $this->_escapeFDF($v) . ')';
             }
-            $fdfFields .= '<</T(' . utf8_decode($k) . ')/' . $val . '>>' . "\n";
+            $fdfFields .= '<</T(' . $this->_escapeFDF($k) . ')/' . $val . '>>' . "\n";
+            $raw .= $k . ': ' . $rawValue . "\n";
         }
 
         if (!$email) {
@@ -73,7 +77,7 @@ trailer
         $recipient = $link['target'] ?: $fluidbook->pdfform_to;
 
         // Admin email
-        Mail::raw($this->_replace($fluidbook->pdfform_email_body), function (Message $message) use ($fluidbook, $recipient, $email, $fields, $tmp, $fdf) {
+        Mail::raw($this->_replace($fluidbook->pdfform_email_body, $raw), function (Message $message) use ($fluidbook, $recipient, $email, $fields, $tmp, $fdf) {
             $message->to($recipient);
             if ($email) {
                 $message->replyTo($email);
@@ -83,7 +87,7 @@ trailer
         });
         // User email
         if ($fluidbook->pdfform_copy_user && $email) {
-            Mail::raw($this->_replace($fluidbook->pdfform_email_body_user), function (Message $message) use ($fluidbook, $recipient, $email, $fields, $tmp, $fdf) {
+            Mail::raw($this->_replace($fluidbook->pdfform_email_body_user, $raw), function (Message $message) use ($fluidbook, $recipient, $email, $fields, $tmp, $fdf) {
                 $message->to($email);
                 $message->replyTo($recipient);
                 $message->subject($this->_replace($fluidbook->pdfform_email_subject_user));
@@ -98,9 +102,15 @@ trailer
 
     }
 
-    protected function _replace($c)
+    protected function _escapeFDF($v)
+    {
+        return utf8_decode(str_replace(['\\', '(', ')'], ['\\\\', '\(', '\)'], $v));
+    }
+
+    protected function _replace($c, $raw = '')
     {
         $c = str_replace('%formname%', $this->_pdfform_link['name'], $c);
+        $c = str_replace('%raw%', $raw, $c);
         return $c;
     }
 }
index ee174584bc3c17dfbdd02eef82518e39bc2d7d92..e6186be87462f95fc142daf554dbc138a6e31529 100644 (file)
@@ -1153,7 +1153,7 @@ trait PublicationSettings
         $this->_addSettingField('', FormSeparator::class);
         $this->_addSettingField('pdfform_to', Email::class, __('Destinataire par défaut'), ['hint' => __('Le destinataire pourra être redéfini pour chaque formulaire dans l\'éditeur de liens')]);
         $this->_addSettingField('pdfform_email_subject', Text::class, __('Sujet des emails pour le destinataire'), ['default' => '%formname%']);
-        $this->_addSettingField('pdfform_email_body', Textarea::class, __('Texte des emails pour le destinataire'));
+        $this->_addSettingField('pdfform_email_body', Textarea::class, __('Texte des emails pour le destinataire'), ['default' => '%raw%']);
 
     }