mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-16 22:45:04 -05:00
Make sure the References header doesn't exceed 998 characters and the value won't get Q-encoded. Thanks to fiouzy for providing the patch.
Fixes issue 1559
This commit is contained in:
parent
6afb8c8506
commit
c29722a56c
@ -368,6 +368,34 @@ public class MimeMessage extends Message
|
|||||||
@Override
|
@Override
|
||||||
public void setReferences(String references) throws MessagingException
|
public void setReferences(String references) throws MessagingException
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* Make sure the References header doesn't exceed 998 characters and
|
||||||
|
* won't get (Q-)encoded later. Otherwise some clients will break
|
||||||
|
* threads apart.
|
||||||
|
*
|
||||||
|
* For more information see issue 1559.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Make sure separator is SPACE to prevent Q-encoding when TAB is encountered
|
||||||
|
references = references.replaceAll("\\s+", " ");
|
||||||
|
|
||||||
|
final int limit = 986; // "References: "
|
||||||
|
final int originalLength = references.length();
|
||||||
|
if (originalLength >= limit)
|
||||||
|
{
|
||||||
|
// Find start of first reference
|
||||||
|
final int start = references.indexOf('<');
|
||||||
|
|
||||||
|
// First reference + SPACE
|
||||||
|
final String firstReference = references.substring(start,
|
||||||
|
references.indexOf('<', start + 1));
|
||||||
|
|
||||||
|
// Find longest tail
|
||||||
|
final String tail = references.substring(references.indexOf('<',
|
||||||
|
firstReference.length() + originalLength - limit));
|
||||||
|
|
||||||
|
references = firstReference + tail;
|
||||||
|
}
|
||||||
setHeader("References", references);
|
setHeader("References", references);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user