From 9d02246e9dfea3d49af0806bb4724a0b025ca563 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 14 May 2026 19:38:03 -0700 Subject: [PATCH 1/2] improvement(gmail): replace custom html-to-text regex with html-to-text library Resolves 4 CodeQL alerts on htmlToPlainText (incomplete tag/entity handling, unsafe regex backtracking). Delegates to the html-to-text npm package already used by the outlook polling trigger and the mail/send route. --- apps/sim/tools/gmail/utils.test.ts | 8 ++++---- apps/sim/tools/gmail/utils.ts | 24 ++++++------------------ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/apps/sim/tools/gmail/utils.test.ts b/apps/sim/tools/gmail/utils.test.ts index 2b56007bf0..bd46d65fc2 100644 --- a/apps/sim/tools/gmail/utils.test.ts +++ b/apps/sim/tools/gmail/utils.test.ts @@ -81,9 +81,9 @@ describe('plainTextToHtml', () => { }) describe('htmlToPlainText', () => { - it('strips tags, decodes entities, and collapses whitespace', () => { + it('strips tags and decodes entities', () => { const result = htmlToPlainText('

Hi & bye

Line
break

') - expect(result).toBe('Hi & bye\nLine\nbreak') + expect(result).toBe('Hi & bye\n\nLine\nbreak') }) it('drops