[ 
https://issues.apache.org/jira/browse/TS-4797?focusedWorklogId=28051&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-28051
 ]

ASF GitHub Bot logged work on TS-4797:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Sep/16 08:36
            Start Date: 03/Sep/16 08:36
    Worklog Time Spent: 10m 
      Work Description: 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 &line) : _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 <bar>");
      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 \\<bar\\>");
      CHECK_EQ(p.getTokens().size(), 3);
    }
    
    // This works either way.
    {                                                                           
   
      ParserTest p("add-header foo \"<bar>\"");
      CHECK_EQ(p.getTokens().size(), 3);
      CHECK_EQ(p.getTokens()[0], "add-header");
      CHECK_EQ(p.getTokens()[1], "foo");
      CHECK_EQ(p.getTokens()[2], "<bar>");
    }
    ```
    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.


Issue Time Tracking
-------------------

    Worklog Id:     (was: 28051)
    Time Spent: 1h  (was: 50m)

> Backslash-escape is not allowed in rewriting rules
> --------------------------------------------------
>
>                 Key: TS-4797
>                 URL: https://issues.apache.org/jira/browse/TS-4797
>             Project: Traffic Server
>          Issue Type: Bug
>          Components: Plugins
>            Reporter: Masaori Koshiba
>             Fix For: 7.0.0
>
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> I noticed that backslash-escape in quoted-string is not allowed in 
> header-rewrite plugin rules. IIRC, this is allowed in 5.3.x.
> e.g.
> {noformat}
> cond %{SEND_RESPONSE_HDR_HOOK}
> add-header Public-Key-Pins 
> "pin-sha256=\"UgXZQmS15cJoBeWTvbmCE+PGw5/oHV00e+MMyuXr0YQ=\"; 
> pin-sha256=\"eYKlKmvqHnR4CsglcYuNzvro7rrmFINrje5nSAxnEsc=\"; max-age=600; 
> includeSubDomains" [L]
> {noformat}
> I got below error
> {noformat}
> 20160830.16h19m34s [header_rewrite] malformed line "add-header 
> Public-Key-Pins "pin-sha256=\"UgXZQmS15cJoBeWTvbmCE+PGw5/oHV00e+MMyuXr0YQ=\"; 
> pin-sha256=\"eYKlKmvqHnR4CsglcYuNzvro7rrmFINrje5nSAxnEsc=\"; max-age=600; 
> includeSubDomains" [L]" ignoring...
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to