cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r1096623 - /cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Date Mon, 25 Apr 2011 22:34:31 GMT
Author: bimargulies
Date: Mon Apr 25 22:34:31 2011
New Revision: 1096623

URL: http://svn.apache.org/viewvc?rev=1096623&view=rev
Log:
Fix content ids in multipart.

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=1096623&r1=1096622&r2=1096623&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java Mon Apr
25 22:34:31 2011
@@ -152,14 +152,23 @@ public final class AttachmentUtil {
         throws IOException {
      
         String id = headers.getHeader("Content-ID", null);
-        if (id != null && id.startsWith("<")) {
-            id = id.substring(1, id.length() - 1);
-        } else {
+        if (id != null) {
+            if (id.startsWith("<")) {
+                // strip <>
+                id = id.substring(1, id.length() - 1);
+            }
+            // strip cid:
+            if (id.startsWith("cid:")) {
+                id = id.substring(4);
+            }
+            // urldecode. Is this bad even without cid:? What does decode do with malformed
%-signs, anyhow?
+            id = URLDecoder.decode(id, "UTF-8");
+        }
+        if (id == null) {
             //no Content-ID, set cxf default ID
-            id = "Content-ID: <root.message@cxf.apache.org";
+            id = "root.message@cxf.apache.org";
         }
 
-        id = URLDecoder.decode(id.startsWith("cid:") ? id.substring(4) : id, "UTF-8");
 
         AttachmentImpl att = new AttachmentImpl(id);
         



Mime
View raw message