Skip to content

Commit 26f7b96

Browse files
Potential fix for code scanning alert no. 43: Incomplete multi-character sanitization
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 4597235 commit 26f7b96

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/api/sqs/handlers/emailNotifications.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ Handlebars.registerHelper("nl2br", (text) => {
1717
const compiledTemplate = Handlebars.compile(emailTemplate);
1818

1919
const stripHtml = (html: string): string => {
20-
return sanitizeHtml(
21-
html
22-
.replace(/<[^>]*>/g, "") // Remove HTML tags
23-
.replace(/&nbsp;/g, " ") // Replace non-breaking spaces
24-
.replace(/\s+/g, " ") // Normalize whitespace
25-
.trim(),
26-
);
20+
// Remove all HTML tags and attributes, then normalize whitespace and trim
21+
const sanitized = sanitizeHtml(html, { allowedTags: [], allowedAttributes: {} });
22+
return sanitized.replace(/\s+/g, " ").trim();
2723
};
2824

2925
export const emailNotificationsHandler: SQSHandlerFunction<

0 commit comments

Comments
 (0)