You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2019/01/08 14:11:26 UTC
[knox] branch master updated: KNOX-1727 - Values should not be
forced in query parameters when proxying through Knox
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new 193502a KNOX-1727 - Values should not be forced in query parameters when proxying through Knox
193502a is described below
commit 193502a3000b04d2121364dd0b3989cd70df99f0
Author: Kevin Risden <kr...@apache.org>
AuthorDate: Mon Jan 7 12:23:30 2019 -0500
KNOX-1727 - Values should not be forced in query parameters when proxying through Knox
Signed-off-by: Kevin Risden <kr...@apache.org>
---
.../java/org/apache/knox/gateway/util/HttpUtils.java | 9 ++++-----
.../org/apache/knox/gateway/util/HttpUtilsTest.java | 19 ++++++++++---------
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
index c318854..ac96214 100644
--- a/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
+++ b/gateway-util-common/src/main/java/org/apache/knox/gateway/util/HttpUtils.java
@@ -28,7 +28,6 @@ import java.util.Map;
import java.util.StringTokenizer;
public class HttpUtils {
-
public static Map<String, List<String>> splitQuery(String queryString)
throws UnsupportedEncodingException {
final Map<String, List<String>> queryPairs = new LinkedHashMap<>();
@@ -42,10 +41,10 @@ public class HttpUtils {
if (!queryPairs.containsKey(key)) {
queryPairs.put(key, new ArrayList<>());
}
- final String value = idx > 0 && pair.length() > idx + 1
- ? URLDecoder.decode(pair.substring(idx + 1), StandardCharsets.UTF_8.name()) : "";
- queryPairs.get(key).add(value);
- }
+ final String value = idx > 0 && pair.length() > idx
+ ? URLDecoder.decode(pair.substring(idx + 1), StandardCharsets.UTF_8.name()) : null;
+ queryPairs.get(key).add(value);
+ }
return queryPairs;
}
diff --git a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/HttpUtilsTest.java b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/HttpUtilsTest.java
index 13b92c3..05aea58 100644
--- a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/HttpUtilsTest.java
+++ b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/HttpUtilsTest.java
@@ -25,6 +25,7 @@ import java.util.List;
import java.util.Map;
import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
@@ -126,28 +127,28 @@ public class HttpUtilsTest {
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "test-name" ), is( true ) );
assertThat( map.get( "test-name" ).size(), is( 1 ) );
- assertThat( map.get( "test-name" ).get(0), is("") );
+ assertThat( map.get( "test-name" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "=test-value" );
assertThat( map, notNullValue() );
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "=test-value" ), is( true ) );
assertThat( map.get( "=test-value" ).size(), is( 1 ) );
- assertThat( map.get( "=test-value" ).get(0), is( "" ) );
+ assertThat( map.get( "=test-value" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "=" );
assertThat( map, notNullValue() );
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "=" ), is( true ) );
assertThat( map.get( "=" ).size(), is( 1 ) );
- assertThat( map.get( "=" ).get(0), is( "" ) );
+ assertThat( map.get( "=" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "==" );
assertThat( map, notNullValue() );
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "==" ), is( true ) );
assertThat( map.get( "==" ).size(), is( 1 ) );
- assertThat( map.get( "==" ).get(0), is( "" ) );
+ assertThat( map.get( "==" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "&" );
assertThat( map, notNullValue() );
@@ -159,14 +160,14 @@ public class HttpUtilsTest {
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "?" ), is( true ) );
assertThat( map.get( "?" ).size(), is( 1 ) );
- assertThat( map.get( "?" ).get(0), is("") );
+ assertThat( map.get( "?" ).get(0), nullValue() );
map = HttpUtils.splitQuery( ";" );
assertThat( map, notNullValue() );
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( ";" ), is( true ) );
assertThat( map.get( ";" ).size(), is( 1 ) );
- assertThat( map.get( ";" ).get(0), is("") );
+ assertThat( map.get( ";" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "&=" );
assertThat( map, notNullValue() );
@@ -174,17 +175,17 @@ public class HttpUtilsTest {
assertThat( map.keySet(), is(new LinkedHashSet<>(Arrays.asList("", "="))));
assertThat( map.containsKey( "" ), is( true ) );
assertThat( map.get( "" ).size(), is( 1 ) );
- assertThat( map.get( "" ).get(0), is( "" ) );
+ assertThat( map.get( "" ).get(0), nullValue() );
assertThat( map.containsKey( "=" ), is( true ) );
assertThat( map.get( "=" ).size(), is( 1 ) );
- assertThat( map.get( "=" ).get(0), is("") );
+ assertThat( map.get( "=" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "=&" );
assertThat( map, notNullValue() );
assertThat( map.size(), is( 1 ) );
assertThat( map.containsKey( "=" ), is( true ) );
assertThat( map.get( "=" ).size(), is( 1 ) );
- assertThat( map.get( "=" ).get(0), is( "" ) );
+ assertThat( map.get( "=" ).get(0), nullValue() );
map = HttpUtils.splitQuery( "&&" );
assertThat( map, notNullValue() );