You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by su...@apache.org on 2014/09/12 18:47:27 UTC

git commit: [TS-3023] - Support space separated values in inline plugin parameters in remap rules

Repository: trafficserver
Updated Branches:
  refs/heads/master 3935dca18 -> 85afd76e0


[TS-3023] - Support space separated values in inline plugin parameters in remap rules


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/85afd76e
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/85afd76e
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/85afd76e

Branch: refs/heads/master
Commit: 85afd76e07380161dc3268a1b5d3bdd7286a9527
Parents: 3935dca
Author: Sudheer Vinukonda <su...@yahoo-inc.com>
Authored: Fri Sep 12 16:47:03 2014 +0000
Committer: Sudheer Vinukonda <su...@yahoo-inc.com>
Committed: Fri Sep 12 16:47:03 2014 +0000

----------------------------------------------------------------------
 lib/ts/Tokenizer.cc             | 13 +++++++++++++
 lib/ts/Tokenizer.h              |  2 ++
 proxy/InkAPITest.cc             | 10 ++++++++++
 proxy/http/remap/RemapConfig.cc |  2 +-
 4 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/85afd76e/lib/ts/Tokenizer.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Tokenizer.cc b/lib/ts/Tokenizer.cc
index 459e54e..78e2cde 100644
--- a/lib/ts/Tokenizer.cc
+++ b/lib/ts/Tokenizer.cc
@@ -55,6 +55,7 @@ Tokenizer::Tokenizer(const char *StrOfDelimiters)
 
   add_node = &start_node;
   add_index = 0;
+  quoteFound = false;
 }
 
 Tokenizer::~Tokenizer()
@@ -95,6 +96,14 @@ Tokenizer::isDelimiter(char c)
 {
   int i = 0;
 
+  if ((options & ALLOW_SPACES) &&
+      ((c == 0x22) || (c == 0x27))) {
+    quoteFound = !quoteFound;
+  }
+
+  if (quoteFound)
+    return 0;
+
   while (strOfDelimit[i] != '\0') {
     if (c == strOfDelimit[i]) {
       return 1;
@@ -182,6 +191,8 @@ Tokenizer::Initialize(char *str, int opt)
     }
   }
 
+  quoteFound = false;
+
   // Check to see if we stoped due to a maxToken limit
   if (max_limit_hit == true) {
 
@@ -215,6 +226,8 @@ Tokenizer::Initialize(char *str, int opt)
       }
     }
   }
+
+  quoteFound = false;
   // Check to see if we got the last token.  We will
   //  only have gotten it if the string ended with a delimiter
   if (priorCharWasDelimit == 0) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/85afd76e/lib/ts/Tokenizer.h
----------------------------------------------------------------------
diff --git a/lib/ts/Tokenizer.h b/lib/ts/Tokenizer.h
index fdc99c5..bfb6a4a 100644
--- a/lib/ts/Tokenizer.h
+++ b/lib/ts/Tokenizer.h
@@ -107,6 +107,7 @@
 #define COPY_TOKS         1 << 0
 #define SHARE_TOKS        1 << 1
 #define ALLOW_EMPTY_TOKS  1 << 2
+#define ALLOW_SPACES      1 << 3
 
 #define TOK_NODE_ELEMENTS  16
 struct tok_node
@@ -154,6 +155,7 @@ private:
   int numValidTokens;
   int maxTokens;
   int options;
+  bool quoteFound;
 
   // State about where to add the next token
   tok_node *add_node;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/85afd76e/proxy/InkAPITest.cc
----------------------------------------------------------------------
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 1345979..52ba3a1 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -7508,6 +7508,16 @@ REGRESSION_TEST(SDK_API_OVERRIDABLE_CONFIGS) (RegressionTest * test, int /* atyp
     *pstatus = REGRESSION_TEST_FAILED;
   }
 
+  Tokenizer whiteTok(" \t");
+
+  char cur_line[] = "map https://abc.com https://abc.com @plugin=conf_remap.so @pparam=proxy.config.abc='ABC DEF'";
+
+  int tok_count = whiteTok.Initialize((char*)cur_line, (SHARE_TOKS | ALLOW_SPACES));
+
+  for (int i=0; i<tok_count; i++) {
+    SDK_RPRINT(test, "Tokenizer::Initialize", "TokenizerTest", TC_PASS, "Token %d : %s\n", i, whiteTok[i]);
+  }
+
   return;
 }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/85afd76e/proxy/http/remap/RemapConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/http/remap/RemapConfig.cc b/proxy/http/remap/RemapConfig.cc
index a713da4..2bbc67c 100644
--- a/proxy/http/remap/RemapConfig.cc
+++ b/proxy/http/remap/RemapConfig.cc
@@ -922,7 +922,7 @@ remap_parse_config_bti(const char * path, BUILD_TABLE_INFO * bti)
 
     Debug("url_rewrite", "[BuildTable] Parsing: \"%s\"", cur_line);
 
-    tok_count = whiteTok.Initialize(cur_line, SHARE_TOKS);
+    tok_count = whiteTok.Initialize(cur_line, (SHARE_TOKS | ALLOW_SPACES));
 
     for (int j = 0; j < tok_count; j++) {
       if (((char *) whiteTok[j])[0] == '@') {