Author: hilmer
Date: Tue Aug 23 02:46:24 2005
New Revision: 239384

URL: http://svn.apache.org/viewcvs?rev=239384&view=rev
Log:
Strip RFC-821 source routing information. JAMES-296


Modified:
    james/server/trunk/src/java/org/apache/mailet/MailAddress.java

Modified: james/server/trunk/src/java/org/apache/mailet/MailAddress.java
URL: 
http://svn.apache.org/viewcvs/james/server/trunk/src/java/org/apache/mailet/MailAddress.java?rev=239384&r1=239383&r2=239384&view=diff
==============================================================================
--- james/server/trunk/src/java/org/apache/mailet/MailAddress.java (original)
+++ james/server/trunk/src/java/org/apache/mailet/MailAddress.java Tue Aug 23 
02:46:24 2005
@@ -71,6 +71,21 @@
     private int pos = 0;
 
     /**
+     * strip source routing, according to RFC-2821 it is an allowed approach 
to handle mails
+     * contaning RFC-821 source-route information
+     */
+    private void stripSourceRoute(String address) throws ParseException {
+        if (pos < address.length()) {
+            if(address.charAt(pos)=='@') { 
+                int i = address.indexOf(':');
+                if(i != -1) {
+                    pos = i+1;
+                }
+            }
+        }
+    }
+    
+    /**
      * <p>Construct a MailAddress parsing the provided <code>String</code> 
object.</p>
      *
      * <p>The <code>personal</code> variable is left empty.</p>
@@ -80,6 +95,11 @@
      */
     public MailAddress(String address) throws ParseException {
         address = address.trim();
+
+        // Test if mail address has source routing information (RFC-821) and 
get rid of it!!
+        //must be called first!! (or at least prior to updating pos)
+        stripSourceRoute(address);
+
         StringBuffer userSB = new StringBuffer();
         StringBuffer hostSB = new StringBuffer();
         //Begin parsing



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to