[GitHub] trafficserver pull request #951: TS-4797: Allow backslash-escape in header_r...

2016-09-07 Thread masaori335
Github user masaori335 closed the pull request at:

https://github.com/apache/trafficserver/pull/951


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #951: TS-4797: Allow backslash-escape in header_r...

2016-09-03 Thread maskit
Github user maskit commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/951#discussion_r77433626
  
--- Diff: plugins/header_rewrite/parser.cc ---
@@ -50,6 +52,12 @@ Parser::Parser(const std::string ) : _cond(false), 
_empty(false)
 _tokens.push_back(std::string(1, line[i]));
   }
   continue; /* always eat whitespace */
+} else if (line[i] == '\\') {
+  // erase a backslash in quoted-string
+  if (inquote && extracting_token) {
--- End diff --

Without this change, the test below passes.
```
{   
  
ParserTest p("add-header foo \\var\\"); 

CHECK_EQ(p.getTokens().size(), 3);  

CHECK_EQ(p.getTokens()[0], "add-header");   

 
CHECK_EQ(p.getTokens()[1], "foo");  

CHECK_EQ(p.getTokens()[2], "\\var\\");  

}
```

But with this change, it fails.
The test case will need to be changed like:
```
CHECK_EQ(p.getTokens()[2], "var\\");
```
This seems very odd. Even if there is no actual use case, it's hard to 
understand the behavior.

However, it seems we don't support backslash-escaping completely outside of 
a quoted string string now, actually.
```
// This doesn't work but it's OK, maybe.
{
  ParserTest p("add-header foo ");
  CHECK_EQ(p.getTokens().size(), 3);
}

// This doesn't work even without Masaori's change. I guess this is the 
case James pointed out.
{
  ParserTest p("add-header foo \\");
  CHECK_EQ(p.getTokens().size(), 3);
}

// This works either way.
{   
   
  ParserTest p("add-header foo \"\"");
  CHECK_EQ(p.getTokens().size(), 3);
  CHECK_EQ(p.getTokens()[0], "add-header");
  CHECK_EQ(p.getTokens()[1], "foo");
  CHECK_EQ(p.getTokens()[2], "");
}
```
I don't know whether this is a regression.

Anyway, more conservative codes would be:
```
if (!extracting_token) {
  extracting_token = true;
  cur_token_start  = i;
}
if (inquote) {
line.erase(i, 1);
continue;
}
```

I think we should add all test cases above to clarify the cases now we 
support.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #951: TS-4797: Allow backslash-escape in header_r...

2016-09-01 Thread masaori335
Github user masaori335 commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/951#discussion_r77287760
  
--- Diff: plugins/header_rewrite/parser.cc ---
@@ -50,6 +52,12 @@ Parser::Parser(const std::string ) : _cond(false), 
_empty(false)
 _tokens.push_back(std::string(1, line[i]));
   }
   continue; /* always eat whitespace */
+} else if (line[i] == '\\') {
+  // erase a backslash in quoted-string
+  if (inquote && extracting_token) {
--- End diff --

My commit message might be not suitable. What I want to fix is we can't use 
**double quote** inside of quoted string.

We can make this more general, but it makes header_rewrite rules and parser 
code more complicated.
Do you have any specific use cases to escape something outside of quoted 
string?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] trafficserver pull request #951: TS-4797: Allow backslash-escape in header_r...

2016-09-01 Thread jpeach
Github user jpeach commented on a diff in the pull request:

https://github.com/apache/trafficserver/pull/951#discussion_r77249993
  
--- Diff: plugins/header_rewrite/parser.cc ---
@@ -50,6 +52,12 @@ Parser::Parser(const std::string ) : _cond(false), 
_empty(false)
 _tokens.push_back(std::string(1, line[i]));
   }
   continue; /* always eat whitespace */
+} else if (line[i] == '\\') {
+  // erase a backslash in quoted-string
+  if (inquote && extracting_token) {
--- End diff --

Why the ``inquote`` condition? Why can't backquotes work outside of a 
quoted string?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---