[BUILD-FAILURE]: Job 'james/ApacheJames/master [master] [1351]'

2024-04-29 Thread Apache Jenkins Server
BUILD-FAILURE: Job 'james/ApacheJames/master [master] [1351]':
Check console output at "https://ci-builds.apache.org/job/james/job/ApacheJames/job/master/1351/;>james/ApacheJames/master
 [master] [1351]"

-
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

(james-mime4j) branch master updated: MIME4J-328 Fix DecoderUtil split point (#101)

2024-04-29 Thread btellier
This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git


The following commit(s) were added to refs/heads/master by this push:
 new ff415b3a MIME4J-328 Fix DecoderUtil split point (#101)
ff415b3a is described below

commit ff415b3a664066818b7e9ed1ad65f36d9e1fd0f2
Author: Benoit TELLIER 
AuthorDate: Mon Apr 29 14:29:19 2024 +0200

MIME4J-328 Fix DecoderUtil split point (#101)

Huge thanks to Chung dae hyun
---
 .../org/apache/james/mime4j/codec/DecoderUtil.java | 62 ++
 .../apache/james/mime4j/codec/DecoderUtilTest.java |  7 +++
 2 files changed, 59 insertions(+), 10 deletions(-)

diff --git a/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java 
b/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
index 14a981dd..5526b8fc 100644
--- a/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
+++ b/core/src/main/java/org/apache/james/mime4j/codec/DecoderUtil.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.mime4j.codec;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.lang.ref.SoftReference;
@@ -28,7 +29,6 @@ import java.util.Map;
 
 import org.apache.james.mime4j.io.InputStreams;
 import org.apache.james.mime4j.util.BufferRecycler;
-import org.apache.james.mime4j.util.ByteArrayBuffer;
 import org.apache.james.mime4j.util.CharsetUtil;
 import org.apache.james.mime4j.util.RecycledByteArrayBuffer;
 
@@ -122,6 +122,10 @@ public class DecoderUtil {
 return new String(decodedBytes, charset);
 }
 
+static byte[] decodeByteAryB(String encodedText, DecodeMonitor monitor) 
throws UnsupportedEncodingException {
+return decodeBase64(encodedText, monitor);
+}
+
 /**
  * Decodes an encoded text encoded with the 'Q' encoding (described in
  * RFC 2047) found in a header field body.
@@ -140,6 +144,10 @@ public class DecoderUtil {
 return new String(decodedBytes, charset);
 }
 
+static byte[] decodeByteAryQ(String encodedText, DecodeMonitor monitor) 
throws UnsupportedEncodingException {
+return decodeQuotedPrintable(replaceUnderscores(encodedText), monitor);
+}
+
 static String decodeEncodedWords(String body)  {
 return decodeEncodedWords(body, DecodeMonitor.SILENT);
 }
@@ -208,8 +216,11 @@ public class DecoderUtil {
 Map charsetOverrides)
 throws IllegalArgumentException {
 
+ByteArrayOutputStream out = new ByteArrayOutputStream();
 StringBuilder sb = new StringBuilder();
 int position = 0;
+String mimeCharset ="";
+String encoding ="";
 
 while (position < body.length()) {
 int startPattern = body.indexOf("=?", position);
@@ -217,6 +228,7 @@ public class DecoderUtil {
 if (position == 0) {
 return body;
 }
+appendStringBuffer(fallback, charsetOverrides, out, sb, 
mimeCharset);
 sb.append(body, position, body.length());
 break;
 }
@@ -227,29 +239,48 @@ public class DecoderUtil {
 
 if (charsetEnd < 0 || encodingEnd < 0 || encodedTextEnd < 0) {
 // Invalid pattern
+appendStringBuffer(fallback, charsetOverrides, out, sb, 
mimeCharset);
 sb.append(body, position, startPattern + 2);
 position = startPattern + 2;
 } else if (encodingEnd == encodedTextEnd) {
+appendStringBuffer(fallback, charsetOverrides, out, sb, 
mimeCharset);
 sb.append(body, position, Math.min(encodedTextEnd + 2, 
body.length()));
 position = encodedTextEnd +2;
 } else {
 String separator = body.substring(position, startPattern);
 if ((!CharsetUtil.isWhitespace(separator) || position == 0) && 
!separator.isEmpty()) {
+appendStringBuffer(fallback, charsetOverrides, out, sb, 
mimeCharset);
 sb.append(separator);
 }
-String mimeCharset = body.substring(startPattern + 2, 
charsetEnd);
-String encoding = body.substring(charsetEnd + 1, encodingEnd);
+String mimeCurCharset = body.substring(startPattern + 2, 
charsetEnd);
+String curEncoding = body.substring(charsetEnd + 1, 
encodingEnd);
 String encodedText = body.substring(encodingEnd + 1, 
encodedTextEnd);
 
+if (!mimeCharset.isEmpty() && 
!mimeCurCharset.equals(mimeCharset)){
+appendStringBuffer(fallback, charsetOverrides, out, sb, 
mimeCharset);
+}
+
+if (!encoding.isEmpty() && !curEncoding.equals(encoding)){
+appendStringBuffer(fallback, charsetOverrides, out, sb,