From 19b9696fe29afe5539d411059e071d37d2b5b990 Mon Sep 17 00:00:00 2001 From: Simon Backx Date: Mon, 30 Jan 2023 14:39:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20HTML=20escaping=20of=20f?= =?UTF-8?q?eature=5Fimage=5Fcaption=20in=20newsletters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit no issue feature_image_caption was escaped in the new email stability flow, while that should not happen (bold/underline/...). --- .../services/email-service/batch-sending.test.js | 14 ++++++++++++++ .../email-service/lib/email-templates/template.hbs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ghost/core/test/integration/services/email-service/batch-sending.test.js b/ghost/core/test/integration/services/email-service/batch-sending.test.js index 2beca1af8f..975cd9a3ef 100644 --- a/ghost/core/test/integration/services/email-service/batch-sending.test.js +++ b/ghost/core/test/integration/services/email-service/batch-sending.test.js @@ -743,5 +743,19 @@ describe('Batch sending tests', function () { }); }); + describe('HTML-content', function () { + it('Does not HTML escape feature_image_caption', async function () { + const {html, plaintext} = await sendEmail({ + feature_image: 'https://example.com/image.jpg', + feature_image_caption: 'Testing feature image caption' + }); + // Check html contains text without escaping + assert.match(html, /Testing feature image caption<\/b>/); + + // Check plaintext version dropped the bold tag + assert.match(plaintext, /Testing feature image caption/); + }); + }); + // TODO: Replacement fallbacks }); diff --git a/ghost/email-service/lib/email-templates/template.hbs b/ghost/email-service/lib/email-templates/template.hbs index 6c3f7330ec..3404f5a8ab 100644 --- a/ghost/email-service/lib/email-templates/template.hbs +++ b/ghost/email-service/lib/email-templates/template.hbs @@ -105,7 +105,7 @@ {{#if post.feature_image_caption }} - {{post.feature_image_caption}} + {{{post.feature_image_caption}}} {{/if}} {{/if}}