james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1157370 - in /james/mime4j/trunk/dom/src: main/java/org/apache/james/mime4j/dom/address/Mailbox.java test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
Date Sat, 13 Aug 2011 11:32:09 GMT
Author: olegk
Date: Sat Aug 13 11:32:08 2011
New Revision: 1157370

URL: http://svn.apache.org/viewvc?rev=1157370&view=rev
Log:
MIME4J-202: allow for mailboxes with empty local part in the lenient mode

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java?rev=1157370&r1=1157369&r2=1157370&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/address/Mailbox.java
Sat Aug 13 11:32:08 2011
@@ -55,7 +55,7 @@ public class Mailbox extends Address {
      */
     public Mailbox(String name, DomainList route, String localPart,
             String domain) {
-        if (localPart == null || localPart.length() == 0)
+        if (localPart == null)
             throw new IllegalArgumentException();
 
         this.name = name == null || name.length() == 0 ? null : name;

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java?rev=1157370&r1=1157369&r2=1157370&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/LenientAddressBuilderTest.java
Sat Aug 13 11:32:08 2011
@@ -61,6 +61,24 @@ public class LenientAddressBuilderTest e
         assertEquals("some one@somehost.somewhere.com", mailbox.getAddress());
     }
 
+    public void testParseMailboxNullAddress() throws Exception {
+        String s = "<>";
+        ByteSequence raw = ContentUtil.encode(s);
+        ParserCursor cursor = new ParserCursor(0, s.length());
+
+        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
+        assertEquals("", mailbox.getAddress());
+    }
+    
+    public void testParseMailboxEmptyAddress() throws Exception {
+        String s = "<    >";
+        ByteSequence raw = ContentUtil.encode(s);
+        ParserCursor cursor = new ParserCursor(0, s.length());
+
+        Mailbox mailbox = parser.parseMailboxAddress(null, raw, cursor);
+        assertEquals("", mailbox.getAddress());
+    }
+    
     public void testParseAddressQuotedLocalPart() throws Exception {
         String s = "<  \"some  one\"   @ some host . some where . com >";
         ByteSequence raw = ContentUtil.encode(s);



Mime
View raw message