Skip to content

Commit

Permalink
MAILBOX-288 Removing all MIME4J limitations on other uses
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Feb 28, 2017
1 parent 3602b25 commit 8164bad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Expand Up @@ -45,6 +45,13 @@
public class MimeDescriptorImpl implements MimeDescriptor {

private final static Charset US_ASCII = Charset.forName("US-ASCII");
private static final MimeConfig MIME_ENTITY_CONFIG = MimeConfig.custom()
.setMaxContentLen(-1)
.setMaxHeaderCount(-1)
.setMaxHeaderLen(-1)
.setMaxHeaderCount(-1)
.setMaxLineLen(-1)
.build();


/**
Expand All @@ -62,9 +69,8 @@ public static boolean isComposite(String mediaType) {
public static MimeDescriptorImpl build(InputStream stream) throws IOException, MimeException {
// Disable line length limit
// See https://issues.apache.org/jira/browse/IMAP-132
MimeConfig config = MimeConfig.custom().setMaxLineLen(-1).setMaxHeaderLen(-1).build();
//
final MimeTokenStream parser = new MimeTokenStream(config, new DefaultBodyDescriptorBuilder());
final MimeTokenStream parser = new MimeTokenStream(MIME_ENTITY_CONFIG, new DefaultBodyDescriptorBuilder());

parser.parse(stream);

Expand Down
Expand Up @@ -40,6 +40,14 @@

public class PartContentBuilder {

private static final MimeConfig MIME_ENTITY_CONFIG = MimeConfig.custom()
.setMaxContentLen(-1)
.setMaxHeaderCount(-1)
.setMaxHeaderLen(-1)
.setMaxHeaderCount(-1)
.setMaxLineLen(-1)
.build();

private static final byte[] EMPTY = {};

private final MimeTokenStream parser;
Expand All @@ -49,9 +57,7 @@ public class PartContentBuilder {
private boolean topLevel = true;

public PartContentBuilder() {
MimeConfig config = MimeConfig.custom().setMaxLineLen(-1).setMaxHeaderLen(-1).build();

parser = new MimeTokenStream(config);
parser = new MimeTokenStream(MIME_ENTITY_CONFIG);
}

public void markEmpty() {
Expand Down

0 comments on commit 8164bad

Please sign in to comment.