james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1156724 - /james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java
Date Thu, 11 Aug 2011 18:44:35 GMT
Author: norman
Date: Thu Aug 11 18:44:35 2011
New Revision: 1156724

URL: http://svn.apache.org/viewvc?rev=1156724&view=rev
Log:
Try to return the raw header value when passing back MessageResult

Modified:
    james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java

Modified: james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java
URL: http://svn.apache.org/viewvc/james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java?rev=1156724&r1=1156723&r2=1156724&view=diff
==============================================================================
--- james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java
(original)
+++ james/mailbox/trunk/store/src/main/java/org/apache/james/mailbox/store/ResultUtils.java
Thu Aug 11 18:44:35 2011
@@ -45,6 +45,9 @@ import org.apache.james.mime4j.parser.Ab
 import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.stream.Field;
 import org.apache.james.mime4j.stream.MimeConfig;
+import org.apache.james.mime4j.stream.RawField;
+import org.apache.james.mime4j.util.ByteSequence;
+import org.apache.james.mime4j.util.ContentUtil;
 
 /**
  *
@@ -69,7 +72,18 @@ public class ResultUtils {
             }
             @Override
             public void field(Field field) throws MimeException {
-                String fieldValue = field.getBody();
+                String fieldValue;
+                if (field instanceof RawField) {
+                    // check if we can access the body in the raw form so no unfolding was
done under the hood
+                    ByteSequence raw = field.getRaw();
+                    int len = raw.length();
+                    int off = ((RawField) field).getDelimiterIdx() + 1;
+                    if (len > off + 1 && (raw.byteAt(off) & 0xff) == 0x20)
off++;
+                
+                    fieldValue = ContentUtil.decode(raw, off, len - off);
+                } else {
+                    fieldValue = field.getBody();
+                }
                 if (fieldValue.endsWith("\r\f")) {
                     fieldValue = fieldValue.substring(0,fieldValue.length() - 2);
                 }



---------------------------------------------------------------------
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