Limit length of references header

This commit is contained in:
M66B 2021-03-27 15:28:01 +01:00
parent 9fb6afd762
commit a5e0d8f086
2 changed files with 16 additions and 2 deletions

View File

@ -3680,6 +3680,9 @@ public class FragmentCompose extends FragmentBase {
"list".equals(action) ||
"dsn".equals(action) ||
"participation".equals(action)) {
// https://tools.ietf.org/html/rfc5322#section-3.6.4
// 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).
data.draft.references = (ref.references == null ? "" : ref.references + " ") + ref.msgid;
data.draft.inreplyto = ref.msgid;
data.draft.thread = ref.thread;

View File

@ -197,8 +197,19 @@ public class MessageHelper {
}
// References
if (message.references != null)
imessage.addHeader("References", message.references);
if (message.references != null) {
// https://tools.ietf.org/html/rfc5322#section-2.1.1
// Each line of characters MUST be no more than 998 characters
String references = message.references;
int hlen = "References: ".length();
int sp = references.indexOf(' ');
while (references.length() > 998 - hlen && sp > 0) {
Log.i("Dropping reference=" + references.substring(0, sp));
references = references.substring(sp);
sp = references.indexOf(' ');
}
imessage.addHeader("References", references);
}
if (message.inreplyto != null)
imessage.addHeader("In-Reply-To", message.inreplyto);
imessage.addHeader(HEADER_CORRELATION_ID, message.msgid);