james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r737075 - /james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java
Date Fri, 23 Jan 2009 16:43:07 GMT
Author: mwiederkehr
Date: Fri Jan 23 08:43:06 2009
New Revision: 737075

URL: http://svn.apache.org/viewvc?rev=737075&view=rev
Log:
MIME4J-107: hashCode() and equals() treat the local-part of an address as case-sensitive (thanks
Stefano).

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

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java?rev=737075&r1=737074&r2=737075&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/address/Mailbox.java Fri
Jan 23 08:43:06 2009
@@ -195,6 +195,20 @@
         return getCanonicalizedAddress().hashCode();
     }
 
+    /**
+     * Indicates whether some other object is "equal to" this mailbox.
+     * <p>
+     * An object is considered to be equal to this mailbox if it is an instance
+     * of class <code>Mailbox</code> that holds the same address as this one.
+     * The domain is considered to be case-insensitive but the local-part is not
+     * (because of RFC 5321: <cite>the local-part of a mailbox MUST BE treated
+     * as case sensitive</cite>).
+     * 
+     * @param obj
+     *            the object to test for equality.
+     * @return <code>true</code> if the specified object is a
+     *         <code>Mailbox</code> that holds the same address as this one.
+     */
     @Override
     public boolean equals(Object obj) {
         if (obj == this)
@@ -213,7 +227,11 @@
     }
 
     private Object getCanonicalizedAddress() {
-        return getAddress().toLowerCase(Locale.US);
+        if (domain == null) {
+            return localPart;
+        } else {
+            return localPart + '@' + domain.toLowerCase(Locale.US);
+        }
     }
 
 }



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


Mime
View raw message