From ea2f7685463a41a121d70675e8ef1110a4f48ea4 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 24 Nov 2022 10:48:04 +0100 Subject: [PATCH] Limit thread info parameters --- .../java/eu/faircode/email/MessageHelper.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/MessageHelper.java b/app/src/main/java/eu/faircode/email/MessageHelper.java index 111af79cd9..b30cbac42f 100644 --- a/app/src/main/java/eu/faircode/email/MessageHelper.java +++ b/app/src/main/java/eu/faircode/email/MessageHelper.java @@ -1440,6 +1440,7 @@ public class MessageHelper { String msgid = getMessageID(); List refs = new ArrayList<>(); + for (String ref : getReferences()) if (!TextUtils.isEmpty(ref) && !refs.contains(ref)) refs.add(ref); @@ -1551,14 +1552,20 @@ public class MessageHelper { String msgid = getMessageID(); List refs = new ArrayList<>(); - for (String ref : getReferences()) - if (!TextUtils.isEmpty(ref) && !refs.contains(ref)) - refs.add(ref); String inreplyto = getInReplyTo(); if (!TextUtils.isEmpty(inreplyto) && !refs.contains(inreplyto)) refs.add(inreplyto); + // The "References:" field will contain the contents of the parent's "References:" field (if any) + // followed by the contents of the parent's "Message-ID:" field (if any). + String[] r = getReferences(); + for (int i = r.length - 1; i >= 0; i--) { + String ref = r[i]; + if (!TextUtils.isEmpty(ref) && !refs.contains(ref)) + refs.add(ref); + } + boolean forward_new = prefs.getBoolean("forward_new", true); if (!forward_new) try { @@ -1571,9 +1578,14 @@ public class MessageHelper { DB db = DB.getInstance(context); - List all = new ArrayList<>(refs); + List all = new ArrayList<>(); if (!TextUtils.isEmpty(msgid)) all.add(msgid); + all.addAll(refs); + + // https://www.sqlite.org/limits.html + if (all.size() > 450) + all = all.subList(0, 450); int thread_range = prefs.getInt("thread_range", MessageHelper.DEFAULT_THREAD_RANGE); int range = (int) Math.pow(2, thread_range);