knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [05/23] knox git commit: KNOX-1055 - Spark page characters & should be treated as a delimiter (Mars via Sandeep More)
Date Mon, 16 Oct 2017 17:05:59 GMT
KNOX-1055 - Spark page characters & should be treated as a delimiter (Mars via Sandeep
More)


Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/90f1df7f
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/90f1df7f
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/90f1df7f

Branch: refs/heads/KNOX-998-Package_Restructuring
Commit: 90f1df7f5b4ed33a9462a46f2fc5afff032890a2
Parents: c5aedf4
Author: Sandeep More <more@apache.org>
Authored: Mon Oct 2 11:37:24 2017 -0400
Committer: Sandeep More <more@apache.org>
Committed: Mon Oct 2 11:37:24 2017 -0400

----------------------------------------------------------------------
 .../hadoop/gateway/util/urltemplate/Parser.java    | 10 +++++++---
 .../gateway/util/urltemplate/ParserTest.java       | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/90f1df7f/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Parser.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Parser.java
b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Parser.java
index e59cd32..a752b22 100644
--- a/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Parser.java
+++ b/gateway-util-urltemplate/src/main/java/org/apache/hadoop/gateway/util/urltemplate/Parser.java
@@ -238,10 +238,14 @@ public class Parser {
 
   private static void consumeQueryToken( final Builder builder, String token ) {
     if( token != null ) {
-      StringTokenizer tokenizer = new StringTokenizer( token, "?&" );
-      while( tokenizer.hasMoreTokens() ) {
-        consumeQuerySegment( builder, tokenizer.nextToken() );
+      //add "&amp;" as a delimiter
+      String[] tokens = token.split("(&amp;|\\?|&)");
+      if (tokens != null){
+        for (String nextToken : tokens){
+          consumeQuerySegment(builder,nextToken);
+        }
       }
+
     }
   }
 

http://git-wip-us.apache.org/repos/asf/knox/blob/90f1df7f/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
index f6d1ab2..4305e11 100644
--- a/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
+++ b/gateway-util-urltemplate/src/test/java/org/apache/hadoop/gateway/util/urltemplate/ParserTest.java
@@ -343,6 +343,23 @@ public class ParserTest {
     assertThat( template.toString(), is( text ) );
   }
 
+  /**
+   *  KNOX-1055
+   *  In some cases & could be encoded as &amp;
+   */
+  @Test
+  public void testEncodedChar() throws URISyntaxException {
+    Parser parser = new Parser();
+    String text;
+    Template template;
+
+    text = "stage?id=007&amp;attempt=0";
+    template = parser.parseTemplate( text );
+    assertBasics( template, false, false, true, 1, 2 );
+    assertQuery( template, "id", "", "007" );
+    assertQuery( template, "attempt", "", "0" );
+  }
+
   @Test
   public void testParameterizedPathTemplatesWithWildcardAndRegex() throws URISyntaxException
{
     String text;


Mime
View raw message