Skip to content

Commit

Permalink
[MP-1010] Fix ampersand in email_subject_room_name
Browse files Browse the repository at this point in the history
  • Loading branch information
dasha140132 committed Oct 25, 2020
1 parent 10af010 commit e4c4b1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/lib/server/functions/notifications/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function getEmailData({
const emailSubject = Mailer.replace(settings.get(subjectKey), {
user: username,
room: roomTypes.getRoomName(room.t, room),
});
}, ['room']);
const content = getEmailContent({
message,
user: receiver,
Expand Down
6 changes: 3 additions & 3 deletions app/mailer/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ settings.get('Language', (key, value) => {
lng = value || 'en';
});

export const replacekey = (str, key, value = '') => str.replace(new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'), s.escapeHTML(value));
export const replacekey = (str, key, value = '', nonEscapeKeys = []) => str.replace(new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'), nonEscapeKeys && nonEscapeKeys.includes(key) ? value : s.escapeHTML(value));
export const translate = (str) => str.replace(/\{ ?([^\} ]+)(( ([^\}]+))+)? ?\}/gmi, (match, key) => TAPi18n.__(key, { lng }));
export const replace = function replace(str, data = {}) {
export const replace = function replace(str, data = {}, nonEscapeKeys = []) {
if (!str) {
return '';
}
Expand All @@ -39,7 +39,7 @@ export const replace = function replace(str, data = {}) {
},
...data,
};
return Object.entries(options).reduce((ret, [key, value]) => replacekey(ret, key, value), translate(str));
return Object.entries(options).reduce((ret, [key, value]) => replacekey(ret, key, value, nonEscapeKeys), translate(str));
};

const nonEscapeKeys = ['room_path'];
Expand Down

0 comments on commit e4c4b1c

Please sign in to comment.