Skip to content

Commit 8e35aa6

Browse files
authored
Merge pull request #1001 from rocket-admin/backend_company_email_a_tag
feat: add utility to wrap strings in <a> tags and apply in HTML data generation
2 parents e65877a + 32c9c4c commit 8e35aa6

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

backend/src/entities/email/utils/escape-html.util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ export function escapeHtml(unsafe: string): string {
66
.replace(/"/g, '&quot;')
77
.replace(/'/g, '&#039;');
88
}
9+
10+
export function wrapStringInTagAWithoutLink(stringToWrap: string): string {
11+
return `<a>${stringToWrap}</a>`;
12+
}

backend/src/helpers/constants/constants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
parseTestIbmDB2ConnectionString,
1313
parseTestDynamoDBConnectionString,
1414
} from '../parsers/string-connection-to-database-parsers.js';
15-
import { escapeHtml } from '../../entities/email/utils/escape-html.util.js';
15+
import { escapeHtml, wrapStringInTagAWithoutLink } from '../../entities/email/utils/escape-html.util.js';
1616
import { isTest } from '../app/is-test.js';
1717

1818
export type TestConnectionsFromJSON = {
@@ -1039,6 +1039,7 @@ export const Constants = {
10391039
},
10401040
GROUP_INVITE_HTML_DATA: function (groupTitle: string) {
10411041
groupTitle = escapeHtml(groupTitle);
1042+
groupTitle = wrapStringInTagAWithoutLink(groupTitle);
10421043
return `
10431044
<!doctype html>
10441045
<html>
@@ -1196,6 +1197,7 @@ export const Constants = {
11961197
companyName: string,
11971198
) {
11981199
companyName = escapeHtml(companyName);
1200+
companyName = wrapStringInTagAWithoutLink(companyName);
11991201
const domain = customCompanyDomain ? customCompanyDomain : Constants.APP_DOMAIN_ADDRESS;
12001202
return `
12011203
<!doctype html>
@@ -1361,6 +1363,7 @@ export const Constants = {
13611363
},
13621364
COMPANY_2FA_ENABLED_HTML_DATA: (companyName: string): string => {
13631365
companyName = escapeHtml(companyName);
1366+
companyName = wrapStringInTagAWithoutLink(companyName);
13641367
return `
13651368
<body>
13661369
<p>

0 commit comments

Comments
 (0)