Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Emails being sent with HTML entities getting escaped multiple times #21994

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { passwordPolicy } from '../lib/passwordPolicy';
import { validateEmailDomain } from '../lib';
import { validateUserRoles } from '../../../../ee/app/authorization/server/validateUserRoles';
import { saveUserIdentity } from './saveUserIdentity';
import { escapeHTML } from '../../../../lib/escapeHTML';

import { checkEmailAvailability, checkUsernameAvailability, setUserAvatar, setEmail, setStatusText } from '.';

Expand All @@ -34,13 +33,13 @@ function _sendUserEmail(subject, html, userData) {
subject,
html,
data: {
email: escapeHTML(userData.email),
password: escapeHTML(userData.password),
email: userData.email,
password: userData.password,
},
};

if (typeof userData.name !== 'undefined') {
email.data.name = escapeHTML(userData.name);
email.data.name = userData.name;
}

try {
Expand Down
8 changes: 7 additions & 1 deletion app/mailer/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ settings.get('Language', (key, value) => {
lng = value || 'en';
});

export const replacekey = (str, key, value = '') => str.replace(new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'), escapeHTML(value));

export const replacekey = (str, key, value = '') => str.replace(
new RegExp(`(\\[${ key }\\]|__${ key }__)`, 'igm'),
value,
);

export const translate = (str) => replaceVariables(str, (match, key) => TAPi18n.__(key, { lng }));
export const replace = function replace(str, data = {}) {
if (!str) {
Expand Down Expand Up @@ -54,6 +59,7 @@ export const replaceEscaped = (str, data = {}) => replace(str, {
return ret;
}, {}),
});

export const wrap = (html, data = {}) => {
if (settings.get('email_plain_text_only')) {
return replace(html, data);
Expand Down