From 338eedc17a210d994c2d8af822bcd2a8a3677f83 Mon Sep 17 00:00:00 2001 From: Roland Tapken Date: Thu, 12 Oct 2023 11:26:41 +0200 Subject: [PATCH] Fixed NullPointerException when attachment hasn't filename attribute --- .../sourceforge/MSGViewer/factory/mbox/JavaMailParser.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParser.java b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParser.java index 3eb0553..1fe2d0b 100644 --- a/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParser.java +++ b/MSGViewer/src/main/java/net/sourceforge/MSGViewer/factory/mbox/JavaMailParser.java @@ -106,7 +106,12 @@ private static void parse(Message msg, Part part) throws MessagingException, IOE MimePart mpart = (MimePart) part; FileAttachment att = new FileAttachment(); - String filename = MimeUtility.decodeText(part.getFileName()); + String filename = part.getFileName(); + if (filename != null) { + filename = MimeUtility.decodeText(filename); + } else { + filename = "unknown"; + } att.setMimeTag(getMime(part.getContentType())); att.setLongFilename(filename);