This is an automated email from the ASF dual-hosted git repository.
rcordier 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 ea6ff944 MIME4J-197 Fixup case Mailbox parser absent domain part
ea6ff944 is described below
commit ea6ff94407216bf3c57daca82dafcb668e90e774
Author: Tung Tran <[email protected]>
AuthorDate: Mon Apr 22 14:55:53 2024 +0700
MIME4J-197 Fixup case Mailbox parser absent domain part
---
.../apache/james/mime4j/field/address/LenientAddressParser.java | 2 +-
dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java | 9 +++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git
a/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressParser.java
b/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressParser.java
index 153f449e..99f130ae 100644
---
a/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressParser.java
+++
b/dom/src/main/java/org/apache/james/mime4j/field/address/LenientAddressParser.java
@@ -152,7 +152,7 @@ public class LenientAddressParser implements AddressParser {
}
pos = cursor.getPos();
current = (char) (buf.byteAt(pos) & 0xff);
- if (current == AT) {
+ if (current == AT || current == CLOSING_BRACKET) {
cursor.updatePos(pos + 1);
} else {
return createMailbox(openingText, domainList, localPart, null);
diff --git a/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
b/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
index 63364791..96fdf6aa 100644
--- a/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
@@ -21,6 +21,7 @@ package org.apache.james.mime4j.field;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@@ -399,6 +400,14 @@ public class FieldsTest {
decode(field));
}
+ @Test
+ public void testAddressListWhenMailboxAbsentDomain() {
+ Mailbox mailbox = new Mailbox("name1", "localpart", "");
+ AddressListField field = Fields.addressList("To",
Collections.singleton(mailbox));
+ Assert.assertEquals(1, field.getAddressList().size());
+ Assert.assertEquals(mailbox, field.getAddressList().get(0));
+ }
+
@Test
public void testInvalidFieldName() throws Exception {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]