Skip to content

Commit

Permalink
Chore: copy data argument to avoid mutate origin.
Browse files Browse the repository at this point in the history
copy data argument passed to mail.send method to avoid mutate original variable
  • Loading branch information
gring2 committed Dec 4, 2023
1 parent 8a7e4eb commit 03b49b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/mail/src/classes/mail-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,20 @@ class MailService {
//Send mail
try {

// copy object to avoid mutating original
const args = data;
//Append multiple flag to data if not set
if (typeof data.isMultiple === 'undefined') {
data.isMultiple = isMultiple;
args.isMultiple = isMultiple;
}

//Append global substitution wrappers if not set in data
if (typeof data.substitutionWrappers === 'undefined') {
data.substitutionWrappers = this.substitutionWrappers;
args.substitutionWrappers = this.substitutionWrappers;
}

//Create Mail instance from data and get JSON body for request
const mail = Mail.create(data);
const mail = Mail.create(args);
const body = mail.toJSON();

//Filters the Mail body to avoid sensitive content leakage
Expand Down

0 comments on commit 03b49b6

Please sign in to comment.