diff --git a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java index 596e5adde..20a28e880 100644 --- a/apps/susimail/src/src/i2p/susi/webmail/WebMail.java +++ b/apps/susimail/src/src/i2p/susi/webmail/WebMail.java @@ -28,6 +28,7 @@ import i2p.susi.util.Config; import i2p.susi.util.DecodingOutputStream; import i2p.susi.util.EscapeHTMLOutputStream; import i2p.susi.util.EscapeHTMLWriter; +import i2p.susi.util.FileBuffer; import i2p.susi.util.FilenameUtil; import i2p.susi.util.Folder; import i2p.susi.util.Folder.SortOrder; @@ -1203,8 +1204,41 @@ public class WebMail extends HttpServlet if( buf.length() > 0 ) cc = buf.toString(); } + I2PAppContext ctx = I2PAppContext.getGlobalContext(); if( forward ) { - // TODO attachments are not forwarded + List parts = part.parts; + if (!parts.isEmpty()) { + // Copy each valid attachment from the mail to a file + // in Drafts/attachments and add to list + // This is similar to the add attachment code in processComposeButtons() + attachments = new ArrayList(parts.size()); + MailCache drafts = sessionObject.caches.get(DIR_DRAFTS); + for (MailPart mp : parts) { + if (mp.name == null || mp.type == null || mp.encoding == null) { + if (log.shouldDebug()) + log.debug("skipping fwd att: " + mp); + continue; + } + String temp = "susimail-attachment-" + ctx.random().nextLong(); + File f; + if (drafts != null) { + f = new File(drafts.getAttachmentDir(), temp); + } else { + f = new File(ctx.getTempDir(), temp); + } + Buffer out = new FileBuffer(f); + boolean ok = false; + try { + mp.decode(0, out); + ok = true; + attachments.add(new Attachment(mp.name, mp.type, mp.encoding, f)); + } catch (IOException e) { + sessionObject.error += _t("Error reading uploaded file: {0}", e.getMessage()) + '\n'; + } finally { + out.writeComplete(ok); + } + } + } subject = mail.subject; if (!(subject.startsWith("Fwd:") || subject.startsWith("fwd:") || @@ -1242,7 +1276,7 @@ public class WebMail extends HttpServlet // then P-R-G in processRequest() StringBuilder draft = composeDraft(sessionObject, from, to, cc, bcc, subject, text.toString(), attachments); - String draftuidl = I2PAppContext.getGlobalContext().random().nextLong() + "drft"; + String draftuidl = ctx.random().nextLong() + "drft"; boolean ok = saveDraft(sessionObject, draftuidl, draft); if (ok) { sessionObject.draftUIDL = draftuidl; diff --git a/history.txt b/history.txt index 3932ed68b..0532f7257 100644 --- a/history.txt +++ b/history.txt @@ -1,3 +1,10 @@ +2018-04-22 zzz + * SusiMail: Include attachments when forwarding (ticket #2087) + +2018-04-21 zzz + * SusiMail: Remove Bcc-to-self feature, replace with + copy-to-sent config (ticket #2087) + 2018-04-19 zzz * SusiMail: - Fix reply/forward filling in compose form diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 4e28a2c8d..c10128fe6 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 5; + public final static long BUILD = 6; /** for example "-test" */ public final static String EXTRA = "";