Cole Greer created TINKERPOP-3318:
-------------------------------------

             Summary: GremlinScriptChecker treats comment markers inside string 
literals as comments
                 Key: TINKERPOP-3318
                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3318
             Project: TinkerPop
          Issue Type: Bug
          Components: server
    Affects Versions: 3.8.2, 3.7.7
            Reporter: Cole Greer


Before looking for {{with()}} request options, {{GremlinScriptChecker}} strips 
comments from the script. It doesn't recognize string literals, so {{//}} or 
{{/*}} inside a string is treated as the start of a comment. The text after it 
is dropped, and any {{with()}} option in that text is silently missed. The 
script still runs, but with the server's default timeout or {{requestId}} 
instead of the one it asked for.

Example:
{code:groovy}
g.V().has('url', 'http://example.com').with('evaluationTimeout', 1000L)
{code}
Expected: a timeout of 1000 ms. Actual: no timeout found, because everything 
after {{//}} is stripped and the checker only sees {{g.V().has('url','http:}}.

A {{/*}} inside a string has the same effect, up to the next {{*/}} anywhere in 
the script:
{code:groovy}
g.inject('/* not a comment').with('evaluationTimeout', 1000L).inject('*/')
{code}

This affects 3.7-dev, 3.8-dev and master. Master uses {{timeoutMillis}} in 
place of {{evaluationTimeout}}.

A fix needs comment stripping to skip over Groovy string literals: {{'...'}}, 
{{"..."}}, {{'''...'''}} and {{"""..."""}}, including escaped quotes. Slashy 
strings ({{/.../}}) are an open question, because they use {{/}} itself as the 
delimiter.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to