Skip to content

Commit

Permalink
Ensure emails are sanitized (#2059)
Browse files Browse the repository at this point in the history
Fixes "incomplete string escaping or encoding" raised by code scanning
  • Loading branch information
harryzcy authored Feb 9, 2025
1 parent 45420e4 commit e67e2cf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/src/contexts/DraftEmailContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,12 @@ const parseAddress = (
let displayName = ''
let email = ''

if (address.includes('<')) {
const countSubstring = (str: string, sub: string) => {
return str.split(sub).length - 1
}
if (countSubstring(address, '<') == 1 && countSubstring(address, '>') == 1) {
displayName = address.split('<')[0].trim()
email = address.split('<')[1].replace('>', '').trim()
email = address.split('<')[1].replaceAll('>', '').trim()

if (displayName.startsWith('"') && displayName.endsWith('"')) {
displayName = displayName.slice(1, -1)
Expand Down

0 comments on commit e67e2cf

Please sign in to comment.