|
|
@ -50,7 +50,6 @@ import com.sun.mail.util.FolderClosedIOException;
|
|
|
|
import com.sun.mail.util.MessageRemovedIOException;
|
|
|
|
import com.sun.mail.util.MessageRemovedIOException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveEntry;
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveEntry;
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveException;
|
|
|
|
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveInputStream;
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveInputStream;
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
|
|
|
|
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
|
|
|
|
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
|
|
|
|
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
|
|
|
@ -99,8 +98,6 @@ import java.util.TimeZone;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.UUID;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.activation.DataHandler;
|
|
|
|
import javax.activation.DataHandler;
|
|
|
|
import javax.activation.FileDataSource;
|
|
|
|
import javax.activation.FileDataSource;
|
|
|
@ -149,7 +146,8 @@ public class MessageHelper {
|
|
|
|
static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
|
|
|
|
static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
|
|
|
|
static final int MAX_SUBJECT_AGE = 48; // hours
|
|
|
|
static final int MAX_SUBJECT_AGE = 48; // hours
|
|
|
|
static final int DEFAULT_THREAD_RANGE = 7; // 2^7 = 128 days
|
|
|
|
static final int DEFAULT_THREAD_RANGE = 7; // 2^7 = 128 days
|
|
|
|
static final int MAX_UNZIP = 10;
|
|
|
|
static final int MAX_UNZIP_COUNT = 20;
|
|
|
|
|
|
|
|
static final long MAX_UNZIP_SIZE = 1000 * 1000 * 1000L;
|
|
|
|
|
|
|
|
|
|
|
|
static final List<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
|
|
|
|
static final List<String> RECEIVED_WORDS = Collections.unmodifiableList(Arrays.asList(
|
|
|
|
"from", "by", "via", "with", "id", "for"
|
|
|
|
"from", "by", "via", "with", "id", "for"
|
|
|
@ -3395,6 +3393,7 @@ public class MessageHelper {
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Gzipped attachment seq=" + local.sequence + " " + name + ":" + total);
|
|
|
|
Log.i("Gzipped attachment seq=" + local.sequence + " " + name + ":" + total);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (total <= MAX_UNZIP_SIZE) {
|
|
|
|
if (name == null &&
|
|
|
|
if (name == null &&
|
|
|
|
local.name != null && local.name.endsWith(".gz"))
|
|
|
|
local.name != null && local.name.endsWith(".gz"))
|
|
|
|
name = local.name.substring(0, local.name.length() - 3);
|
|
|
|
name = local.name.substring(0, local.name.length() - 3);
|
|
|
@ -3435,6 +3434,7 @@ public class MessageHelper {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
db.attachment().setDownloaded(attachment.id, efile.length());
|
|
|
|
db.attachment().setDownloaded(attachment.id, efile.length());
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
Log.e(ex);
|
|
|
|
Log.e(ex);
|
|
|
|
db.attachment().setWarning(local.id, Log.formatThrowable(ex));
|
|
|
|
db.attachment().setWarning(local.id, Log.formatThrowable(ex));
|
|
|
@ -3447,12 +3447,15 @@ public class MessageHelper {
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
ArchiveEntry entry;
|
|
|
|
ArchiveEntry entry;
|
|
|
|
while ((entry = ais.getNextEntry()) != null)
|
|
|
|
while ((entry = ais.getNextEntry()) != null)
|
|
|
|
if (ais.canReadEntryData(entry) && !entry.isDirectory())
|
|
|
|
if (ais.canReadEntryData(entry) && !entry.isDirectory()) {
|
|
|
|
if (++count > MAX_UNZIP)
|
|
|
|
if (entry.getSize() > MAX_UNZIP_SIZE)
|
|
|
|
|
|
|
|
count = MAX_UNZIP_COUNT;
|
|
|
|
|
|
|
|
if (++count > MAX_UNZIP_COUNT)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Zip entries=" + count);
|
|
|
|
Log.i("Zip entries=" + count);
|
|
|
|
if (count <= MAX_UNZIP) {
|
|
|
|
if (count <= MAX_UNZIP_COUNT) {
|
|
|
|
fis.getChannel().position(0);
|
|
|
|
fis.getChannel().position(0);
|
|
|
|
|
|
|
|
|
|
|
|
ais = new ArchiveStreamFactory().createArchiveInputStream(
|
|
|
|
ais = new ArchiveStreamFactory().createArchiveInputStream(
|
|
|
|