cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Fixing empty charset processing errors, patch from emlun applied with thanks
Date Wed, 07 Oct 2015 10:28:19 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 16a5d26bd -> 1a6d4658e


Fixing empty charset processing errors, patch from emlun applied with thanks


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

Branch: refs/heads/3.0.x-fixes
Commit: 1a6d4658e051f021cf1282a9f3dd42b2727fca12
Parents: 16a5d26
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Wed Oct 7 11:25:04 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Wed Oct 7 11:28:02 2015 +0100

----------------------------------------------------------------------
 .../java/org/apache/cxf/helpers/HttpHeaderHelper.java  |  3 +++
 .../org/apache/cxf/helpers/HttpHeaderHelperTest.java   | 13 +++++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/1a6d4658/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java b/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
index 52b1ebe..049691d 100644
--- a/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
+++ b/core/src/main/java/org/apache/cxf/helpers/HttpHeaderHelper.java
@@ -87,6 +87,9 @@ public final class HttpHeaderHelper {
             if (charset.indexOf(";") != -1) {
                 charset = charset.substring(0, charset.indexOf(";")).trim();
             }
+            if (charset.isEmpty()) {
+                return null;
+            }
             if (charset.charAt(0) == '\"') {
                 charset = charset.substring(1, charset.length() - 1);
             }

http://git-wip-us.apache.org/repos/asf/cxf/blob/1a6d4658/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java b/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
index 6239fb4..7fdb41e 100644
--- a/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
+++ b/core/src/test/java/org/apache/cxf/helpers/HttpHeaderHelperTest.java
@@ -20,7 +20,9 @@
 package org.apache.cxf.helpers;
 
 import java.nio.charset.Charset;
+
 import org.junit.Test;
+
 import static org.junit.Assert.assertEquals;
 
 /**
@@ -39,5 +41,16 @@ public class HttpHeaderHelperTest {
         cs = HttpHeaderHelper.mapCharset("'utf-8'");
         assertEquals(Charset.forName("utf-8").name(), cs);
     }
+    
+    @Test 
+    public void testEmptyCharset() {
+        String cs = HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset="));
+        assertEquals("ISO-8859-1", cs);
+    }
+    @Test 
+    public void testEmptyCharset2() {
+        String cs = HttpHeaderHelper.mapCharset(HttpHeaderHelper.findCharset("foo/bar; charset=;"));
+        assertEquals("ISO-8859-1", cs);
+    }
 
 }


Mime
View raw message