[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [BP][FIX] Parser: avoid no-parse markers in mail translations

"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]> Sat, 18 Jul 2026 10:44:23 +0000
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a5b59071cec7_3819d0203143@gitlab-sidekiq-low-urgency-cpu-bound-v2-76655d7f68-6cbzm.mail>

MAGENE Sem Joel pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
04200093 by MAGENE Sem Joel at 2026-07-18T10:37:23+00:00
[BP][FIX] Parser: avoid no-parse markers in mail translations
---
* [FIX] Parser: avoid no-parse markers in mail translations
---
* [FIX] Parser: avoid no-parse markers in mail translations

See merge request tikiwiki/tiki!10656

(cherry picked from commit f3a1e80a65217c2ae0b583e113fe91439176bfdd)

See merge request tikiwiki/tiki!10754

- - - - -


4 changed files:

- lib/test/language/TranslationSanitizationTest.php
- templates/mail/confirm_newsletter_subscription.tpl
- templates/mail/tracker_changed_notification.tpl
- templates/mail/tracker_changed_notification_subject.tpl


Changes:

=====================================
lib/test/language/TranslationSanitizationTest.php
=====================================
@@ -317,6 +317,46 @@ $lang = array_replace($lang, $lang_custom);
         $this->assertStringContainsString('~np~', $result);
         $this->assertStringContainsString('~/np~', $result);
 
+        // Mail translations explicitly opt out because their output is not parsed as wiki text.
+        $smarty->assign([
+            'mail_action' => '',
+            'mail_itemId' => 1381,
+            'mail_item_desc' => 'Ken',
+            'mail_trackerName' => 'Contacts',
+            'mail_user' => 'Ken',
+            'mail_date' => 1,
+            'mail_data' => '',
+            'server_name' => 'example.test',
+        ]);
+        $result = $smarty->fetchLang($this->lang, 'mail/tracker_changed_notification.tpl');
+        $this->assertStringContainsString('View the tracker item at:', $result);
+        $this->assertStringNotContainsString('~np~', $result);
+        $this->assertStringNotContainsString('~/np~', $result);
+
+        $result = $smarty->fetchLang($this->lang, 'mail/tracker_changed_notification_subject.tpl');
+        $this->assertStringContainsString('item', $result);
+        $this->assertStringNotContainsString('~np~', $result);
+        $this->assertStringNotContainsString('~/np~', $result);
+
+        $smarty->assign([
+            'info' => ['name' => 'News', 'description' => 'Description'],
+            'code' => 'confirmation-code',
+        ]);
+        $result = $smarty->fetchLang($this->lang, 'mail/confirm_newsletter_subscription.tpl');
+        $this->assertStringContainsString('To the newsletter:', $result);
+        $this->assertStringNotContainsString('~np~', $result);
+        $this->assertStringNotContainsString('~/np~', $result);
+
+        $repeat = false;
+        $result = $handler->handle(
+            ['lang' => $this->lang],
+            'Edit',
+            $template,
+            $repeat
+        );
+        $this->assertStringContainsString('~np~', $result);
+        $this->assertStringContainsString('~/np~', $result);
+
         // Clean up
         unset($parserlib->option['wiki_parse_context']);
     }


=====================================
templates/mail/confirm_newsletter_subscription.tpl
=====================================
@@ -1,9 +1,9 @@
-{tr}Someone tried to subscribe this email address at our {$prefs.mail_template_custom_text}site:{/tr} {$server_name}
-{tr}To the newsletter:{/tr} {$info.name}
+{tr noparse=n}Someone tried to subscribe this email address at our {$prefs.mail_template_custom_text}site:{/tr} {$server_name}
+{tr noparse=n}To the newsletter:{/tr} {$info.name}
 
-{tr}Description:{/tr}
+{tr noparse=n}Description:{/tr}
 {$info.description}
 
-{tr}Please access the following URL to confirm your subscription:{/tr}
+{tr noparse=n}Please access the following URL to confirm your subscription:{/tr}
 
 {mailurl}tiki-newsletters.php?confirm_subscription={$code}{/mailurl}


=====================================
templates/mail/tracker_changed_notification.tpl
=====================================
@@ -1,34 +1,34 @@
-{if $mail_action eq 'deleted'}{tr}Tracker item {$mail_itemId} was deleted in the tracker {tr}{$mail_trackerName}{/tr} by {tr}{$mail_user|username}{/tr} on {tr}{$mail_date|tiki_short_datetime:"":"n"}{/tr} {/tr}
-{elseif $mail_action eq 'status'}{tr}New status for ItemID {$mail_itemId} {$mail_item_desc} for the {$prefs.mail_template_custom_text}tracker {tr}{$mail_trackerName}:{/tr}{/tr} {if $status eq 'o'}{tr}open{/tr}{elseif $status eq 'p'}{tr}pending{/tr}{elseif $status eq 'c'}{tr}closed{/tr}{/if}
+{if $mail_action eq 'deleted'}{tr noparse=n}Tracker item {$mail_itemId} was deleted in the tracker {tr noparse=n}{$mail_trackerName}{/tr} by {tr noparse=n}{$mail_user|username}{/tr} on {tr noparse=n}{$mail_date|tiki_short_datetime:"":"n"}{/tr} {/tr}
+{elseif $mail_action eq 'status'}{tr noparse=n}New status for ItemID {$mail_itemId} {$mail_item_desc} for the {$prefs.mail_template_custom_text}tracker {tr noparse=n}{$mail_trackerName}:{/tr}{/tr} {if $status eq 'o'}{tr noparse=n}open{/tr}{elseif $status eq 'p'}{tr noparse=n}pending{/tr}{elseif $status eq 'c'}{tr noparse=n}closed{/tr}{/if}
 {else}{$mail_action}
 
-{tr}View the {$prefs.mail_template_custom_text}tracker item at:{/tr}
+{tr noparse=n}View the {$prefs.mail_template_custom_text}tracker item at:{/tr}
     {mailurl}{$mail_itemId|sefurl:'trackeritem'}{/mailurl}
 {/if}
 
 {if $mail_action eq 'deleted'}
 {if $mail_fields}
-{tr}The last content before deletion was as follows:{/tr}
+{tr noparse=n}The last content before deletion was as follows:{/tr}
 
 Status: {$mail_field_status}
 {foreach from=$mail_fields key=id item=item}
 {if !empty($item.value)}
 ----------
-[{tr}{$item.name}{/tr}]:
+[{tr noparse=n}{$item.name}{/tr}]:
 {$item.value}
 {/if}
 {/foreach}
 ----------
 {/if}
 {else}
-{tr}Author:{/tr} {$mail_user|username}
-{tr}Date:{/tr} {$mail_date|tiki_short_datetime:"":"n"}
+{tr noparse=n}Author:{/tr} {$mail_user|username}
+{tr noparse=n}Date:{/tr} {$mail_date|tiki_short_datetime:"":"n"}
 {/if}
 
 {$mail_data|replace:'-[':''|replace:']-':''}{* TODO: translate these -[...]- marked strings in $mail_data by watcher language *}
 {* {$mail_data|replace:"\n\n":"\n"|replace:":\n":": "} to reduce the number of line *}
 
 {if isset($mail_attId)}
-    {tr}Download the file at:{/tr} {mailurl}tiki-download_item_attachment.php?attId={$mail_attId}{/mailurl}
+    {tr noparse=n}Download the file at:{/tr} {mailurl}tiki-download_item_attachment.php?attId={$mail_attId}{/mailurl}
 {/if}
 


=====================================
templates/mail/tracker_changed_notification_subject.tpl
=====================================
@@ -1 +1 @@
-{$prefs.mail_template_custom_text}"{tr}{$mail_trackerName}{/tr}" {tr}item{/tr} "{$mail_item_desc}" {if $mail_action eq 'deleted'}{tr}was deleted at{/tr}{else}{tr}was modified at{/tr}{/if} {$server_name} {tr}by{/tr} "{if not empty($user)}{$user|username}{else}{tr}Anonymous{/tr}{/if}"
+{$prefs.mail_template_custom_text}"{tr noparse=n}{$mail_trackerName}{/tr}" {tr noparse=n}item{/tr} "{$mail_item_desc}" {if $mail_action eq 'deleted'}{tr noparse=n}was deleted at{/tr}{else}{tr noparse=n}was modified at{/tr}{/if} {$server_name} {tr noparse=n}by{/tr} "{if not empty($user)}{$user|username}{else}{tr noparse=n}Anonymous{/tr}{/if}"



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0420009349b37f28e1d012597fa62ae2f4285536

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0420009349b37f28e1d012597fa62ae2f4285536
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs