From 7b7c3dd36fa8404bbfcc19a02d6bc10b2fd9076e Mon Sep 17 00:00:00 2001 From: Alexander Gehrke Date: Thu, 2 Mar 2023 13:20:09 +0100 Subject: [PATCH] mail-notify: fix NPE when sender is only mail address without name --- misc/mail-notify | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misc/mail-notify b/misc/mail-notify index ad897b0..259dfba 100755 --- a/misc/mail-notify +++ b/misc/mail-notify @@ -12,13 +12,13 @@ val icon = "/usr/share/icons/Adwaita/48x48/actions/mail-message-new.png" val cacheFile = envPath("XDG_CACHE_HOME", os.home/".cache") / "seen-mails" val maildir = envPath("MAILDIR", os.home/"Mail") - case class MailInfo(from: String, subject: String, mailbox: String) object MailInfo { def fromPath(p: os.Path, maildir: os.Path) = { val msg = readMessage(p) + val address = msg.getFrom.head.asInstanceOf[InternetAddress] MailInfo( - msg.getFrom.head.asInstanceOf[InternetAddress].getPersonal.replace("&", "&"), + Option(address.getPersonal).map(_.replace("&", "&")).getOrElse(address.getAddress), msg.getSubject.replace("&", "&"), (p/up/up relativeTo maildir).toString )