mirror of
https://github.com/strapi/strapi.git
synced 2025-12-24 13:43:41 +00:00
Add strict interpolate & deactivate evaluation in sendTemplatedEmail
This commit is contained in:
parent
a39fedfb30
commit
d7db946c4e
@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
const {
|
||||
template: { createStrictInterpolationRegExp },
|
||||
} = require('@strapi/utils/');
|
||||
|
||||
const getProviderSettings = () => {
|
||||
return strapi.config.get('plugin.email');
|
||||
@ -26,10 +29,17 @@ const sendTemplatedEmail = (emailOptions = {}, emailTemplate = {}, data = {}) =>
|
||||
);
|
||||
}
|
||||
|
||||
const allowedInterpolationVariables = Object.keys(data).join('|');
|
||||
const interpolate = createStrictInterpolationRegExp(allowedInterpolationVariables, 'g');
|
||||
|
||||
const templatedAttributes = attributes.reduce(
|
||||
(compiled, attribute) =>
|
||||
emailTemplate[attribute]
|
||||
? Object.assign(compiled, { [attribute]: _.template(emailTemplate[attribute])(data) })
|
||||
? Object.assign(compiled, {
|
||||
[attribute]: _.template(emailTemplate[attribute], { interpolate, evaluate: false })(
|
||||
data
|
||||
),
|
||||
})
|
||||
: compiled,
|
||||
{}
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user