Skip to content

Commit 5267f8c

Browse files
authored
Escape special characters in email query (calcom#25079)
1 parent c6ec42e commit 5267f8c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/app-store/salesforce/lib/CrmService.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,8 +553,11 @@ export default class SalesforceCRMService implements CRM {
553553
setFallbackToContact?: boolean;
554554
conn: Connection;
555555
}) {
556+
// Escape SOSL reserved characters: ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -
557+
// eslint-disable-next-line no-useless-escape
558+
const escapedEmail = email.replace(/([?&|!{}[\]()^~*:\\"'+\-])/g, "\\$1");
556559
const searchResult = await conn.search(
557-
`FIND {${email}} IN EMAIL FIELDS RETURNING Lead(Id, Email, OwnerId, Owner.Email), Contact(Id, Email, OwnerId, Owner.Email)`
560+
`FIND {${escapedEmail}} IN EMAIL FIELDS RETURNING Lead(Id, Email, OwnerId, Owner.Email), Contact(Id, Email, OwnerId, Owner.Email)`
558561
);
559562

560563
if (searchResult.searchRecords.length === 0) {

0 commit comments

Comments
 (0)