mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 03:23:45 +08:00
Add null check on email body to prevent cheerio exception (#2298)
This commit is contained in:
parent
187ba07206
commit
f8b8bff5db
1 changed files with 19 additions and 13 deletions
|
@ -66,11 +66,15 @@ interface UnsubscribeAction {
|
|||
}
|
||||
|
||||
function bestUnsubscribeLink(message): string {
|
||||
const dom = cheerio.load(message.body);
|
||||
const links = _getLinks(dom);
|
||||
|
||||
let result = null;
|
||||
|
||||
// Only check the body if it has been downloaded already
|
||||
if (message.body) {
|
||||
|
||||
const dom = cheerio.load(message.body);
|
||||
const links = _getLinks(dom);
|
||||
|
||||
for (const link of links) {
|
||||
for (const re of regexps) {
|
||||
if (re.test(link.href)) {
|
||||
|
@ -86,6 +90,8 @@ function bestUnsubscribeLink(message): string {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue