This is an automated email from the ASF dual-hosted git repository. chibenwa pushed a commit to branch mime-config-tunning in repository https://gitbox.apache.org/repos/asf/james-mime4j.git
commit 6bebfa972ad58611cb2bbdcbbbf943c7d2097b0e Author: Benoit TELLIER <[email protected]> AuthorDate: Fri Oct 23 18:49:31 2026 +0200 [ENHANCEMENT] Allow tunning MimeConfig.PERMISSIVE --- .../org/apache/james/mime4j/stream/MimeConfig.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/org/apache/james/mime4j/stream/MimeConfig.java b/core/src/main/java/org/apache/james/mime4j/stream/MimeConfig.java index f6e44b86..d008d930 100644 --- a/core/src/main/java/org/apache/james/mime4j/stream/MimeConfig.java +++ b/core/src/main/java/org/apache/james/mime4j/stream/MimeConfig.java @@ -26,11 +26,23 @@ import org.apache.james.mime4j.MimeException; */ public final class MimeConfig { + /** + * Lenient profile, still bounded so a single message cannot exhaust the JVM memory. + * + * <p>Its limits can be overridden through system properties, read once at class loading: + * <ul> + * <li>{@code james.mime4j.permissive.max.content.length} (default 100 MB)</li> + * <li>{@code james.mime4j.permissive.max.header.count} (default 4096)</li> + * <li>{@code james.mime4j.permissive.max.header.length} (default 64 KB)</li> + * <li>{@code james.mime4j.permissive.max.line.length} (default -1, unbounded)</li> + * </ul> + * A negative value disables the corresponding check. + */ public static final MimeConfig PERMISSIVE = MimeConfig.custom() - .setMaxContentLen(100 * 1024 * 1024) - .setMaxHeaderCount(4096) - .setMaxHeaderLen(64 * 1024) - .setMaxLineLen(-1) + .setMaxContentLen(Long.getLong("james.mime4j.permissive.max.content.length", 100 * 1024 * 1024)) + .setMaxHeaderCount(Integer.getInteger("james.mime4j.permissive.max.header.count", 4096)) + .setMaxHeaderLen(Integer.getInteger("james.mime4j.permissive.max.header.length", 64 * 1024)) + .setMaxLineLen(Integer.getInteger("james.mime4j.permissive.max.line.length", -1)) .build(); public static final MimeConfig DEFAULT = new Builder().build(); public static final MimeConfig STRICT = new Builder() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
