From ba0afcc487c9ad7267fda16d37e47e2bfd8c6d34 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 14 Nov 2022 10:14:13 +0100 Subject: [PATCH] Fix boundary without quotes --- .../main/java/javax/mail/internet/ContentType.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/javax/mail/internet/ContentType.java b/app/src/main/java/javax/mail/internet/ContentType.java index 2005d2fd66..1e7dcd8deb 100644 --- a/app/src/main/java/javax/mail/internet/ContentType.java +++ b/app/src/main/java/javax/mail/internet/ContentType.java @@ -89,8 +89,18 @@ public class ContentType { // Finally parameters .. String rem = h.getRemainder(); - if (rem != null) - list = new ParameterList(rem); + if (rem != null) { + int b = rem.indexOf("boundary="); + if (b >= 0 && b + 9 < rem.length() && rem.charAt(b + 9) != '"') { + int semi = rem.indexOf(';', b + 9); + if (semi < 0) + rem = rem.substring(0, b + 9) + '"' + rem.substring(b + 9) + '"'; + else + rem = rem.substring(0, b + 9) + '"' + rem.substring(b + 9, semi) + '"' + rem.substring(semi); + eu.faircode.email.Log.w("Fixed boundary: " + rem); + } + list = new ParameterList(rem); + } } /**