From e04b6e438612fc28a57bb9fda98d17a45acd84bd Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Tue, 20 Aug 2024 15:24:08 +0000 Subject: [PATCH 1/2] Fix possible concurrent modification problem Signed-off-by: Arthur Chan --- api/src/main/java/jakarta/mail/internet/ParameterList.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/jakarta/mail/internet/ParameterList.java b/api/src/main/java/jakarta/mail/internet/ParameterList.java index 27b92345..00c4d887 100644 --- a/api/src/main/java/jakarta/mail/internet/ParameterList.java +++ b/api/src/main/java/jakarta/mail/internet/ParameterList.java @@ -429,9 +429,9 @@ private void combineMultisegmentNames(boolean keepConsistentOnFailure) charset = vv.charset; } else { if (charset == null) { - // should never happen - multisegmentNames.remove(name); - break; + // Happened when some invalid string is used. + // Details in Issue#734 + throw new ParseException("Invalid parameter list string."); } } decodeBytes(vv.value, bos); From c10ac86b3d47dc9c079895c2a0ecdd3486be8e38 Mon Sep 17 00:00:00 2001 From: Arthur Chan Date: Wed, 9 Oct 2024 10:21:29 +0000 Subject: [PATCH 2/2] Fix logic Signed-off-by: Arthur Chan --- api/src/main/java/jakarta/mail/internet/ParameterList.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/api/src/main/java/jakarta/mail/internet/ParameterList.java b/api/src/main/java/jakarta/mail/internet/ParameterList.java index 00c4d887..6fa6f7d2 100644 --- a/api/src/main/java/jakarta/mail/internet/ParameterList.java +++ b/api/src/main/java/jakarta/mail/internet/ParameterList.java @@ -429,9 +429,8 @@ private void combineMultisegmentNames(boolean keepConsistentOnFailure) charset = vv.charset; } else { if (charset == null) { - // Happened when some invalid string is used. - // Details in Issue#734 - throw new ParseException("Invalid parameter list string."); + // should never happen + it.remove(name); } } decodeBytes(vv.value, bos);