Add nl2br Handlebars helper and use in template
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

Convert newline characters in email reason text to <br /> tags and ensure proper escaping. Replaced {{reason}} with {{{nl2br reason}}} in the rejection template and registered an nl2br Handlebars helper that escapes HTML entities, transforms newlines to <br /> and returns a SafeString so line breaks render correctly in emails.
This commit is contained in:
jelveh
2026-03-08 15:51:54 -07:00
parent 004777824d
commit 62df3df6a9
+13 -2
View File
@@ -50,9 +50,9 @@ The Puter Team
html: `
<p>Hi{{#if owner_username}} {{owner_username}}{{/if}},</p>
<p>
Thanks for submitting <a href="https://puter.com/app/{{app_name}}">{{app_title}}</a> for the Puter App Center. We reviewed your listing and have rejected it for the following reason:
Thanks for submitting <a href="https://puter.com/app/{{app_name}}">{{app_title}}</a> for the Puter App Center. We reviewed your listing and have rejected it for the following reason(s):
</p>
<blockquote>{{reason}}</blockquote>
<blockquote>{{{nl2br reason}}}</blockquote>
<p>
Please update your app listing and resubmit when ready. If you have questions, just reply to this email.
</p>
@@ -219,6 +219,17 @@ class Emailservice extends BaseService {
_construct () {
this.templates = TEMPLATES;
const handlebars = this.modules.handlebars;
handlebars.registerHelper('nl2br', (text) => {
if ( text == null ) return '';
const s = String(text)
.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;');
return new handlebars.SafeString(s.replace(/\n/g, '<br />'));
});
this.template_fns = {};
for ( const k in this.templates ) {
const template = this.templates[k];