MCPcopy Index your code
hub / github.com/simstudioai/sim / validateAndSanitize

Function validateAndSanitize

apps/sim/lib/messaging/email/prepare.ts:41–65  ·  view source on GitHub ↗
(options: EmailOptions)

Source from the content-addressed store, hash-verified

39}
40
41function validateAndSanitize(options: EmailOptions): {
42 senderEmail: string
43 subject: string
44 replyTo?: string
45} {
46 const senderEmail = options.from || getFromEmailAddress()
47 const recipients = Array.isArray(options.to) ? options.to : [options.to]
48
49 if (recipients.some(hasEmailHeaderControlChars)) {
50 throw new Error('Invalid recipient email header')
51 }
52 if (hasEmailHeaderControlChars(senderEmail)) {
53 throw new Error('Invalid from email header')
54 }
55 if (options.replyTo && hasEmailHeaderControlChars(options.replyTo)) {
56 throw new Error('Invalid reply-to email header')
57 }
58
59 const subject = sanitizeEmailSubject(options.subject)
60 if (subject.length === 0) {
61 throw new Error('Email subject cannot be empty')
62 }
63
64 return { senderEmail, subject, replyTo: options.replyTo }
65}
66
67export function processEmailData(options: EmailOptions): ProcessedEmailData {
68 const { senderEmail, subject, replyTo } = validateAndSanitize(options)

Callers 1

processEmailDataFunction · 0.85

Calls 3

getFromEmailAddressFunction · 0.90
sanitizeEmailSubjectFunction · 0.85

Tested by

no test coverage detected