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: <[email protected]";
+            id = "[email protected]";
         }
 
-        id = URLDecoder.decode(id.startsWith("cid:") ? id.substring(4) : id, 
"UTF-8");
 
         AttachmentImpl att = new AttachmentImpl(id);
         


Reply via email to