[master] 406ec859a Turn newline into the end of a VSL query
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Jun 12 04:58:10 UTC 2019
commit 406ec859a6275086166a8f4dd4ad0028a062f2ca
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Thu May 16 16:40:47 2019 +0200
Turn newline into the end of a VSL query
Instead of treating it as a mere whitespace separator. As a result the
lexer output looks like this:
TOK_1, ..., TOK_N, EOI[, TOK_1, ..., TOK_N, EOI[...]]
At this point though, only the first series of tokens is considered, in
a single query mode that was already what we've had so far. It will also
be the parser's job to ignore consecutive EOI tokens for "empty" queries.
diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c
index b004c55f8..ff5221e41 100644
--- a/lib/libvarnishapi/vxp_lexer.c
+++ b/lib/libvarnishapi/vxp_lexer.c
@@ -103,8 +103,8 @@ vxp_Lexer(struct vxp *vxp)
for (p = vxp->b; p < vxp->e; ) {
- /* Skip any whitespace */
- if (isspace(*p)) {
+ /* Skip any space or tab */
+ if (isblank(*p)) {
p++;
continue;
}
@@ -126,6 +126,8 @@ vxp_Lexer(struct vxp *vxp)
q++;
if (q == vxp->e)
break;
+ } else if (*q == '\n') {
+ break;
} else if (*q == quote) {
q++;
quote = '\0';
@@ -157,6 +159,13 @@ vxp_Lexer(struct vxp *vxp)
continue;
}
+ /* On to the next query */
+ if (*p == '\n') {
+ vxp_add_token(vxp, EOI, p, p + 1);
+ p++;
+ continue;
+ }
+
/* Error */
vxp_add_token(vxp, EOI, p, p + 1);
VSB_printf(vxp->sb, "Syntax error ");
More information about the varnish-commit
mailing list