@@ -319,6 +319,23 @@ export class TableActionActivationService {
319319 return primaryKeyValuesArray ;
320320 }
321321
322+ private escapePrimaryKeyValuesArray ( array : Array < Record < string , unknown > > ) : Array < Record < string , unknown > > {
323+ return array . map ( ( record ) => {
324+ const escapedRecord : Record < string , unknown > = { } ;
325+ for ( const key in record ) {
326+ if ( record . hasOwnProperty ( key ) ) {
327+ const escapedKey = escapeHtml ( key ) ;
328+ // eslint-disable-next-line security/detect-object-injection
329+ const value = record [ key ] ;
330+ const escapedValue = typeof value === 'string' ? escapeHtml ( value ) : value ;
331+ // eslint-disable-next-line security/detect-object-injection
332+ escapedRecord [ escapedKey ] = escapedValue ;
333+ }
334+ }
335+ return escapedRecord ;
336+ } ) ;
337+ }
338+
322339 private generateMessageContent (
323340 userInfo : UserInfoMessageData ,
324341 triggerOperation : TableActionEventEnum ,
@@ -334,8 +351,9 @@ export class TableActionActivationService {
334351 : triggerOperation === TableActionEventEnum . DELETE_ROW
335352 ? 'deleted a row'
336353 : 'performed an action' ;
354+ primaryKeyValuesArray = this . escapePrimaryKeyValuesArray ( primaryKeyValuesArray ) ;
337355 const textContent = `${ userName ? escapeHtml ( userName ) : 'User' } (email: ${ email } , user id: ${ userId } ) has ${ action } in the table "${ escapeHtml ( tableName ) } ".` ;
338- const testContentWithPrimaryKeys = `${ textContent } Primary Keys: ${ escapeHtml ( JSON . stringify ( primaryKeyValuesArray ) ) } ` ;
356+ const testContentWithPrimaryKeys = `${ textContent } Primary Keys: ${ JSON . stringify ( primaryKeyValuesArray ) } ` ;
339357 const htmlContent = `<!doctype html>
340358<html>
341359 <head>
@@ -437,7 +455,7 @@ table[class=body] .article {
437455 <tr>
438456 <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
439457 <p style="font-size: 18px; font-weight: normal; margin: 0; margin-bottom: 15px;">${ textContent } </p>
440- <p style="font-size: 18px; font-weight: normal; margin: 0; margin-bottom: 15px;">Primary Keys: ${ escapeHtml ( JSON . stringify ( primaryKeyValuesArray ) ) } </p>
458+ <p style="font-size: 18px; font-weight: normal; margin: 0; margin-bottom: 15px;">Primary Keys: ${ JSON . stringify ( primaryKeyValuesArray ) } </p>
441459 </td>
442460 </tr>
443461 <tr>
0 commit comments