You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/10/03 14:59:31 UTC

[cxf] branch 3.0.x-fixes updated (bfc8295 -> 29c1740)

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a change to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from bfc8295  Recording .gitmergeinfo Changes
     new a2ce435  CXF-7507 - Put a configurable limit on the size of attachment headers
     new 1f13b65  Recording .gitmergeinfo Changes
     new 29c1740  Fixing merge

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |  4 ++
 .../cxf/attachment/AttachmentDeserializer.java     | 24 ++++++++
 .../apache/cxf/attachment/ContentDisposition.java  |  2 +-
 .../HeaderSizeExceededException.java}              | 12 ++--
 .../java/org/apache/cxf/message/MessageUtils.java  | 24 +++++++-
 .../apache/cxf/jaxrs/ext/MessageContextImpl.java   |  9 ++-
 .../apache/cxf/jaxrs/ext/multipart/Attachment.java |  6 +-
 .../cxf/systest/jaxrs/JAXRSMultipartTest.java      | 64 ++++++++++++++++++++++
 .../apache/cxf/systest/jaxrs/MultipartServer.java  |  1 +
 9 files changed, 134 insertions(+), 12 deletions(-)
 copy core/src/main/java/org/apache/cxf/{io/CacheSizeExceededException.java => attachment/HeaderSizeExceededException.java} (74%)

-- 
To stop receiving notification emails like this one, please contact
['"commits@cxf.apache.org" <co...@cxf.apache.org>'].

[cxf] 02/03: Recording .gitmergeinfo Changes

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 1f13b6519455d2d5eac7c39422f2f8406154ee9b
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 3 14:08:50 2017 +0100

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index 7ea563d..2c91bf6 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -149,6 +149,7 @@ B 13fa5dc1ffebe4e63a27f17528598925af04d570
 B 1444405de684d0a266cbbfbb415e09121412d577
 B 1444d98730b69b95b00067a33e6255d069e0bec1
 B 1487fccd43c3bcc463f12cdc1573cde68323f8b6
+B 148daf38cc5287077400b74fd1b62a614aa0eff7
 B 14ed2e2c44b6da7641c95fb57212f8b5a5e77f3d
 B 150213cac13dc342e9c0a6559f5856edf85e660d
 B 154d06822014f5cc0607cbf12706a31f88577191
@@ -867,6 +868,7 @@ B 6efe475ad57f042ffc9547f1bb258ab4e16a3f3e
 B 6f07ef7b6c5ab9a8c88dd8e4b4d60dac0d2adb6e
 B 6f2a98efabe16b6e129ca86b292b74d006093541
 B 6f31130c52c4f328795c71f7f3891e3b7c899daf
+B 6f3aa6da2bc35bdb578ba341f8c597ec9bab1f25
 B 6f3e4aa162c2ec1c78256b57d98f735cfb15a2fb
 B 6f3f4c1f873d8d30a4c30165280dd0ff46e03d5d
 B 6f48d4a7bc8ab908f3d6d977d3f68d1a0f20f8f4
@@ -1879,6 +1881,7 @@ B f595ca026d56ec5e58a38780677598d8f9d9ded5
 B f5b010990de021fb1084a2b4e164266b9ce0e5c6
 B f5b75c7a061b04a75c12fda170d5caff89c257e1
 B f5b83ad364b11bca9c4d3e70bcc68951e096f8ed
+B f5ffa4e04b34ebdb1f1b3ad34a54e67fa805caf7
 B f6293b0cbfd682a17d0f9549622cace14c68287a
 B f62e5dd8ea53b96fed4c17e32e77ff1844713a17
 B f63e8ad713e6f140420e9de6a4fc2a7686fb1b8e
@@ -2194,6 +2197,7 @@ M 865eb64d44fd4e904f166cb03b0d15ca8b5f0ba5
 M 87bbc7f8110fc2629aeb6a706e83392442ab0507
 M 88a7cd850f0471d6e51f9045bf01f775a905cbf2
 M 88c48ed4b6164afbb7cc97c6a8bffc63babcf5af
+M 896bd961cbbb6b8569700e5b70229f78f94ad9dd
 M 89b87071f3dedd2cd5ed874e56f69ab7dcf7953d
 M 89cc0697c2e19670d3ccfd72c37003a26226b412
 M 8a9952073cf5edffd848c43d63ac173a2c7455a5

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.

[cxf] 01/03: CXF-7507 - Put a configurable limit on the size of attachment headers

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit a2ce435cf0eedc8158d118d6d275114408d2a376
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 3 11:53:04 2017 +0100

    CXF-7507 - Put a configurable limit on the size of attachment headers
    
    # Conflicts:
    #	core/src/main/java/org/apache/cxf/message/MessageUtils.java
    #	rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
    #	rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
    
    # Conflicts:
    #	core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
    #	rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
---
 .../cxf/attachment/AttachmentDeserializer.java     | 24 ++++++++
 .../apache/cxf/attachment/ContentDisposition.java  |  2 +-
 .../attachment/HeaderSizeExceededException.java    | 40 ++++++++++++++
 .../java/org/apache/cxf/message/MessageUtils.java  | 24 +++++++-
 .../apache/cxf/jaxrs/ext/MessageContextImpl.java   |  9 ++-
 .../apache/cxf/jaxrs/ext/multipart/Attachment.java | 11 +++-
 .../cxf/systest/jaxrs/JAXRSMultipartTest.java      | 64 ++++++++++++++++++++++
 .../apache/cxf/systest/jaxrs/MultipartServer.java  |  1 +
 8 files changed, 169 insertions(+), 6 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
index afc3bc5..d950a51 100644
--- a/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
+++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
@@ -29,17 +29,20 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
+import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.activation.DataSource;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.HttpHeaderHelper;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.message.Attachment;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 
 public class AttachmentDeserializer {
     public static final String ATTACHMENT_PART_HEADERS = AttachmentDeserializer.class.getName() + ".headers";
@@ -49,6 +52,12 @@ public class AttachmentDeserializer {
 
     public static final String ATTACHMENT_MAX_SIZE = "attachment-max-size";
 
+    /**
+     * The maximum MIME Header Length. The default is 300.
+     */
+    public static final String ATTACHMENT_MAX_HEADER_SIZE = "attachment-max-header-size";
+    public static final int DEFAULT_MAX_HEADER_SIZE = 300;
+
     public static final int THRESHOLD = 1024 * 100; //100K (byte unit)
 
     private static final Pattern CONTENT_TYPE_BOUNDARY_PATTERN = Pattern.compile("boundary=\"?([^\";]*)");
@@ -58,6 +67,8 @@ public class AttachmentDeserializer {
     private static final Pattern INPUT_STREAM_BOUNDARY_PATTERN =
             Pattern.compile("^--(\\S*)$", Pattern.MULTILINE);
 
+    private static final Logger LOG = LogUtils.getL7dLogger(AttachmentDeserializer.class);
+
     private boolean lazyLoading = true;
 
     private int pbAmount = 2048;
@@ -79,6 +90,8 @@ public class AttachmentDeserializer {
     private Set<DelegatingInputStream> loaded = new HashSet<DelegatingInputStream>();
     private List<String> supportedTypes;
 
+    private int maxHeaderLength = DEFAULT_MAX_HEADER_SIZE;
+
     public AttachmentDeserializer(Message message) {
         this(message, Collections.singletonList("multipart/related"));
     }
@@ -86,6 +99,10 @@ public class AttachmentDeserializer {
     public AttachmentDeserializer(Message message, List<String> supportedTypes) {
         this.message = message;
         this.supportedTypes = supportedTypes;
+
+        // Get the maximum Header length from configuration
+        maxHeaderLength = MessageUtils.getContextualInteger(message, ATTACHMENT_MAX_HEADER_SIZE,
+                                                            DEFAULT_MAX_HEADER_SIZE);
     }
     
     public void initializeAttachments() throws IOException {
@@ -286,6 +303,7 @@ public class AttachmentDeserializer {
             new DelegatingInputStream(new MimeBodyPartInputStream(stream, boundary, pbAmount),
                                       this);
         createCount++;
+
         return AttachmentUtil.createAttachment(partStream, headers);
     }
 
@@ -334,6 +352,7 @@ public class AttachmentDeserializer {
         List<String> headerLines = new ArrayList<String>(10);
         StringBuilder buffer = new StringBuilder(128);
         String line;
+
         // loop until we hit the end or a null line
         while ((line = readLine(in)) != null) {
             // lines beginning with white space get special handling
@@ -412,6 +431,11 @@ public class AttachmentDeserializer {
                 // just add to the buffer
                 buffer.append((char)c);
             }
+
+            if (buffer.length() > maxHeaderLength) {
+                LOG.fine("The attachment header size has exceeded the configured parameter: " + maxHeaderLength);
+                throw new HeaderSizeExceededException();
+            }
         }
 
         // no characters found...this was either an eof or a null line.
diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
index 9ce30e9..4b15771 100644
--- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
+++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
 
 public class ContentDisposition {
     private static final String CD_HEADER_PARAMS_EXPRESSION =
-        "(([\\w-]+( )?\\*?=( )?\"[^\"]+\")|([\\w-]+( )?\\*?=( )?[^;]+))";
+       "[\\w-]++( )?\\*?=( )?((\"[^\"]++\")|([^;]+))";
     private static final Pattern CD_HEADER_PARAMS_PATTERN =
             Pattern.compile(CD_HEADER_PARAMS_EXPRESSION);
 
diff --git a/core/src/main/java/org/apache/cxf/attachment/HeaderSizeExceededException.java b/core/src/main/java/org/apache/cxf/attachment/HeaderSizeExceededException.java
new file mode 100644
index 0000000..69b484e
--- /dev/null
+++ b/core/src/main/java/org/apache/cxf/attachment/HeaderSizeExceededException.java
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.attachment;
+
+public class HeaderSizeExceededException extends RuntimeException {
+    private static final long serialVersionUID = -8976580055837650080L;
+
+    public HeaderSizeExceededException() {
+        super();
+    }
+
+    public HeaderSizeExceededException(String message) {
+        super(message);
+    }
+
+    public HeaderSizeExceededException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public HeaderSizeExceededException(Throwable cause) {
+        super(cause);
+    }
+}
diff --git a/core/src/main/java/org/apache/cxf/message/MessageUtils.java b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
index 5bcfe23..75459a7 100644
--- a/core/src/main/java/org/apache/cxf/message/MessageUtils.java
+++ b/core/src/main/java/org/apache/cxf/message/MessageUtils.java
@@ -19,8 +19,11 @@
 
 package org.apache.cxf.message;
 
+import java.util.logging.Logger;
+
 import org.w3c.dom.Node;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PropertyUtils;
 
 
@@ -29,6 +32,8 @@ import org.apache.cxf.common.util.PropertyUtils;
  */
 public final class MessageUtils {
 
+    private static final Logger LOG = LogUtils.getL7dLogger(MessageUtils.class);
+
     /**
      * Prevents instantiation.
      */
@@ -139,7 +144,24 @@ public final class MessageUtils {
         }
         return defaultValue;
     }
-    
+
+    public static int getContextualInteger(Message m, String key, int defaultValue) {
+        if (m != null) {
+            Object o = m.getContextualProperty(key);
+            if (o instanceof String) {
+                try {
+                    int i = Integer.parseInt((String)o);
+                    if (i > 0) {
+                        return i;
+                    }
+                } catch (NumberFormatException ex) {
+                    LOG.warning("Incorrect integer value of " + o + " specified for: " + key);
+                }
+            }
+        }
+        return defaultValue;
+    }
+
     public static Object getContextualProperty(Message m, String propPreferred, String propDefault) {
         Object prop = null;
         if (m != null) {
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
index f2e5331..4caa2a7 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/MessageContextImpl.java
@@ -45,6 +45,7 @@ import javax.ws.rs.ext.Providers;
 import org.apache.cxf.attachment.AttachmentDeserializer;
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.attachment.AttachmentUtil;
+import org.apache.cxf.attachment.HeaderSizeExceededException;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
@@ -64,6 +65,7 @@ import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.message.MessageUtils;
 
 public class MessageContextImpl implements MessageContext {
+
     private Message m;
     public MessageContextImpl(Message m) {
         this.m = m;
@@ -78,6 +80,8 @@ public class MessageContextImpl implements MessageContext {
             } catch (CacheSizeExceededException e) {
                 m.getExchange().put("cxf.io.cacheinput", Boolean.FALSE);
                 throw new WebApplicationException(e, 413);
+            } catch (HeaderSizeExceededException e) {
+                throw new WebApplicationException(e, 413);
             }
         }
         if (keyValue.equals("WRITE-" + Message.ATTACHMENTS)) {
@@ -269,7 +273,9 @@ public class MessageContextImpl implements MessageContext {
                 m.getExchange().getInMessage().get(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD));
             inMessage.put(AttachmentDeserializer.ATTACHMENT_MAX_SIZE,
                 m.getExchange().getInMessage().get(AttachmentDeserializer.ATTACHMENT_MAX_SIZE));
-            inMessage.setContent(InputStream.class, 
+            inMessage.put(AttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZE,
+                m.getExchange().getInMessage().get(AttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZE));
+            inMessage.setContent(InputStream.class,
                 m.getExchange().getInMessage().get("org.apache.cxf.multipart.embedded.input"));
             inMessage.put(Message.CONTENT_TYPE, 
                 m.getExchange().getInMessage().get("org.apache.cxf.multipart.embedded.ctype").toString());
@@ -282,6 +288,7 @@ public class MessageContextImpl implements MessageContext {
         try {
             Map<String, List<String>> headers 
                 = CastUtils.cast((Map<?, ?>)inMessage.get(AttachmentDeserializer.ATTACHMENT_PART_HEADERS));
+
             Attachment first = new Attachment(AttachmentUtil.createAttachment(
                                      inMessage.getContent(InputStream.class), 
                                      headers),
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
index 58b37b8..4dafe15 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
@@ -88,7 +88,7 @@ public class Attachment implements Transferable {
              new DataHandler(new InputStreamDataSource(is, headers.getFirst("Content-Type"))), 
              headers);
     }
-    
+
     public Attachment(String id, String mediaType, Object object) {
         this.object = object;
         headers.putSingle("Content-ID", id);
@@ -103,8 +103,8 @@ public class Attachment implements Transferable {
         headers.putSingle("Content-ID", id);
         headers.putSingle("Content-Type", "application/octet-stream");
     }
-    
-    Attachment(MultivaluedMap<String, String> headers, DataHandler handler, Object object) {
+
+    public Attachment(MultivaluedMap<String, String> headers, DataHandler handler, Object object) {
         this.headers = headers;
         this.handler = handler;
         this.object = object;
@@ -121,7 +121,12 @@ public class Attachment implements Transferable {
     }
 
     public MediaType getContentType() {
+<<<<<<< HEAD
         String value = handler != null ? handler.getContentType() : headers.getFirst("Content-Type");
+=======
+        String value = handler != null && handler.getContentType() != null ? handler.getContentType()
+            : headers.getFirst("Content-Type");
+>>>>>>> 896bd961cb... CXF-7507 - Put a configurable limit on the size of attachment headers
         return value == null ? MediaType.TEXT_PLAIN_TYPE : JAXRSUtils.toMediaType(value);
     }
 
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
index 16dfeaf..7fa7b70 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
@@ -39,6 +39,7 @@ import javax.activation.DataHandler;
 import javax.imageio.ImageIO;
 import javax.mail.util.ByteArrayDataSource;
 import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
 import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
 import javax.xml.bind.JAXBContext;
@@ -62,6 +63,7 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.ext.multipart.Attachment;
 import org.apache.cxf.jaxrs.ext.multipart.ContentDisposition;
+import org.apache.cxf.jaxrs.ext.multipart.InputStreamDataSource;
 import org.apache.cxf.jaxrs.ext.multipart.MultipartBody;
 import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.provider.json.JSONProvider;
@@ -942,6 +944,67 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase {
         }
     }
 
+    // The large Content Disposition header will be rejected here
+    @Test
+    public void testLargeHeader() throws Exception {
+        InputStream is1 =
+            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
+        String address = "http://localhost:" + PORT + "/bookstore/books/image";
+        WebClient client = WebClient.create(address);
+        client.type("multipart/mixed").accept("multipart/mixed");
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",
+            "true");
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("form-data;");
+        for (int i = 0; i < 10000; i++) {
+            sb.append("aaaaaaaaaa");
+        }
+
+        MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
+        headers.putSingle("Content-ID", "root");
+        headers.putSingle("Content-Type", "application/octet-stream");
+        headers.putSingle("Content-Disposition", sb.toString());
+        DataHandler handler = new DataHandler(new InputStreamDataSource(is1, "application/octet-stream"));
+
+        Attachment att = new Attachment(headers, handler, null);
+        Response response = client.post(att);
+        assertEquals(response.getStatus(), 413);
+
+        client.close();
+    }
+
+    // The Content Disposition header will be accepted here, even though it is larger than the default,
+    // as we have configured a larger value on the service side
+    @Test
+    public void testLargerThanDefaultHeader() throws Exception {
+        InputStream is1 =
+            getClass().getResourceAsStream("/org/apache/cxf/systest/jaxrs/resources/java.jpg");
+        String address = "http://localhost:" + PORT + "/bookstore/books/image";
+        WebClient client = WebClient.create(address);
+        client.type("multipart/mixed").accept("multipart/mixed");
+        WebClient.getConfig(client).getRequestContext().put("support.type.as.multipart",
+            "true");
+
+        StringBuilder sb = new StringBuilder();
+        sb.append("form-data;");
+        for (int i = 0; i < 35; i++) {
+            sb.append("aaaaaaaaaa");
+        }
+
+        MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
+        headers.putSingle("Content-ID", "root");
+        headers.putSingle("Content-Type", "application/octet-stream");
+        headers.putSingle("Content-Disposition", sb.toString());
+        DataHandler handler = new DataHandler(new InputStreamDataSource(is1, "application/octet-stream"));
+
+        Attachment att = new Attachment(headers, handler, null);
+        Response response = client.post(att);
+        assertEquals(response.getStatus(), 200);
+
+        client.close();
+    }
+
     private void doAddBook(String address, String resourceName, int status) throws Exception {
         doAddBook("multipart/related", address, resourceName, status);
     }
@@ -1031,4 +1094,5 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase {
         }
         return str;
     }
+
 }
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
index 0bf1718..0fa7b9a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartServer.java
@@ -40,6 +40,7 @@ public class MultipartServer extends AbstractBusTestServerBase {
         Map<String, Object> props = new HashMap<String, Object>();
         props.put(AttachmentDeserializer.ATTACHMENT_MAX_SIZE, String.valueOf(1024 * 10));
         props.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, String.valueOf(1024 * 5));
+        props.put(AttachmentDeserializer.ATTACHMENT_MAX_HEADER_SIZE, String.valueOf(400));
         sf.setProperties(props);
         //default lifecycle is per-request, change it to singleton
         sf.setResourceProvider(MultipartStore.class,

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.

[cxf] 03/03: Fixing merge

Posted by co...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch 3.0.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 29c1740b4bacc63ed1216e7bed504deff07dd1bf
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 3 15:59:18 2017 +0100

    Fixing merge
---
 core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java | 2 +-
 .../src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java | 5 -----
 .../test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java   | 4 ++--
 3 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
index 4b15771..80dcdfa 100644
--- a/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
+++ b/core/src/main/java/org/apache/cxf/attachment/ContentDisposition.java
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
 
 public class ContentDisposition {
     private static final String CD_HEADER_PARAMS_EXPRESSION =
-       "[\\w-]++( )?\\*?=( )?((\"[^\"]++\")|([^;]+))";
+        "[\\w-]++( )?\\*?=( )?((\"[^\"]++\")|([^;]+))";
     private static final Pattern CD_HEADER_PARAMS_PATTERN =
             Pattern.compile(CD_HEADER_PARAMS_EXPRESSION);
 
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
index 4dafe15..a76deae 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/multipart/Attachment.java
@@ -121,12 +121,7 @@ public class Attachment implements Transferable {
     }
 
     public MediaType getContentType() {
-<<<<<<< HEAD
         String value = handler != null ? handler.getContentType() : headers.getFirst("Content-Type");
-=======
-        String value = handler != null && handler.getContentType() != null ? handler.getContentType()
-            : headers.getFirst("Content-Type");
->>>>>>> 896bd961cb... CXF-7507 - Put a configurable limit on the size of attachment headers
         return value == null ? MediaType.TEXT_PLAIN_TYPE : JAXRSUtils.toMediaType(value);
     }
 
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
index 7fa7b70..e652fb2 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSMultipartTest.java
@@ -961,7 +961,7 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase {
             sb.append("aaaaaaaaaa");
         }
 
-        MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
+        MultivaluedMap<String, String> headers = new MultivaluedHashMap<String, String>();
         headers.putSingle("Content-ID", "root");
         headers.putSingle("Content-Type", "application/octet-stream");
         headers.putSingle("Content-Disposition", sb.toString());
@@ -992,7 +992,7 @@ public class JAXRSMultipartTest extends AbstractBusClientServerTestBase {
             sb.append("aaaaaaaaaa");
         }
 
-        MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
+        MultivaluedMap<String, String> headers = new MultivaluedHashMap<String, String>();
         headers.putSingle("Content-ID", "root");
         headers.putSingle("Content-Type", "application/octet-stream");
         headers.putSingle("Content-Disposition", sb.toString());

-- 
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.