cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-6076] Allowing + chars in media type parameters without quotes
Date Tue, 04 Nov 2014 10:52:46 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 1e02198a0 -> 7a7abbb1a


[CXF-6076] Allowing + chars in media type parameters without quotes


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/7a7abbb1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/7a7abbb1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/7a7abbb1

Branch: refs/heads/2.7.x-fixes
Commit: 7a7abbb1a3bb51a685185d62a293bbce1cecf156
Parents: 1e02198
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Nov 4 10:50:17 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Nov 4 10:52:28 2014 +0000

----------------------------------------------------------------------
 .../cxf/jaxrs/impl/MediaTypeHeaderProvider.java |  2 +-
 .../jaxrs/impl/MediaTypeHeaderProviderTest.java | 34 ++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/7a7abbb1/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
index e9cebf7..0ae2ef1 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProvider.java
@@ -43,7 +43,7 @@ public class MediaTypeHeaderProvider implements HeaderDelegate<MediaType>
{
     private static final String STRICT_MEDIA_TYPE_CHECK = 
         "org.apache.cxf.jaxrs.mediaTypeCheck.strict";
     private static final Pattern COMPLEX_PARAMETERS = 
-        Pattern.compile("(([\\w-]+=\"[^\"]*\")|([\\w-]+=[\\w-/]+))");
+        Pattern.compile("(([\\w-]+=\"[^\"]*\")|([\\w-]+=[\\w-/\\+]+))");
     
     public MediaType fromString(String mType) {
         

http://git-wip-us.apache.org/repos/asf/cxf/blob/7a7abbb1/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
----------------------------------------------------------------------
diff --git a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
index 26099e5..d569a6a 100644
--- a/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
+++ b/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/MediaTypeHeaderProviderTest.java
@@ -36,6 +36,40 @@ public class MediaTypeHeaderProviderTest extends Assert {
     }
     
     @Test
+    public void testTypeWithExtendedParameters() {
+        MediaType mt = MediaType.valueOf("multipart/related;type=application/dicom+xml");
+        
+        assertEquals("multipart", mt.getType());
+        assertEquals("related", mt.getSubtype());
+        Map<String, String> params2 = mt.getParameters();
+        assertEquals(1, params2.size());
+        assertEquals("application/dicom+xml", params2.get("type"));
+    }
+
+    @Test
+    public void testTypeWithExtendedParametersQuote() {
+        MediaType mt = MediaType.valueOf("multipart/related;type=\"application/dicom+xml\"");
+        
+        assertEquals("multipart", mt.getType());
+        assertEquals("related", mt.getSubtype());
+        Map<String, String> params2 = mt.getParameters();
+        assertEquals(1, params2.size());
+        assertEquals("\"application/dicom+xml\"", params2.get("type"));
+    }    
+    
+    @Test
+    public void testTypeWithExtendedAndBoundaryParameter() {
+        MediaType mt = MediaType.valueOf(
+            "multipart/related; type=application/dicom+xml; boundary=\"uuid:b9aecb2a-ab37-48d6-a1cd-b2f4f7fa63cb\"");
+        assertEquals("multipart", mt.getType());
+        assertEquals("related", mt.getSubtype());
+        Map<String, String> params2 = mt.getParameters();
+        assertEquals(2, params2.size());
+        assertEquals("\"uuid:b9aecb2a-ab37-48d6-a1cd-b2f4f7fa63cb\"", params2.get("boundary"));
+        assertEquals("application/dicom+xml", params2.get("type"));
+    }
+    
+    @Test
     public void testSimpleType() {
         MediaType m = MediaType.valueOf("text/html");
         assertEquals("Media type was not parsed correctly", 


Mime
View raw message