Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Distinguish $TYPE.property from $TYPE.method() by insisting in ()
STRING.upper() and STRING.lower() are methods.

Relevant to: #3023
  • Loading branch information
bsdphk committed Aug 14, 2019
1 parent 82ad74a commit 67ea0c8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
16 changes: 8 additions & 8 deletions bin/varnishtest/tests/v00058.vtc
Expand Up @@ -184,14 +184,14 @@ server s1 {

varnish v1 -vcl+backend {
sub vcl_deliver {
set resp.http.l-proto = resp.proto.lower;
set resp.http.u-proto = resp.proto.upper;
set resp.http.l-req = req.url.lower;
set resp.http.u-req = req.url.upper;
set resp.http.l-mod = (req.url + "bar").lower;
set resp.http.u-mod = (req.url + "bar").upper;
set resp.http.uu-mod = (req.url + "bar").upper.upper;
set resp.http.ul-mod = (req.url + "bar").upper.lower;
set resp.http.l-proto = resp.proto.lower();
set resp.http.u-proto = resp.proto.upper();
set resp.http.l-req = req.url.lower();
set resp.http.u-req = req.url.upper();
set resp.http.l-mod = (req.url + "bar").lower();
set resp.http.u-mod = (req.url + "bar").upper();
set resp.http.uu-mod = (req.url + "bar").upper().upper();
set resp.http.ul-mod = (req.url + "bar").upper().lower();
}
}

Expand Down
21 changes: 17 additions & 4 deletions lib/libvcc/vcc_expr.c
Expand Up @@ -803,23 +803,30 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
/*--------------------------------------------------------------------
* SYNTAX:
* Expr4:
* Expr5 [ '.' type_method() ]*
* Expr5 [ '.' (type_attribute | type_method()) ]*
*
* type_attributes is information already existing, requiring no
* processing or resource usage.
*
* type_methods are calls and may do (significant processing, change things,
* eat workspace etc.
*/

static const struct vcc_methods {
vcc_type_t type_from;
vcc_type_t type_to;
const char *method;
const char *impl;
int func;
} vcc_methods[] = {
//{ BACKEND, BOOL, "healthy", "VRT_Healthy(ctx, \v1, 0)" },

#define VRTSTVVAR(nm, vtype, ctype, dval) \
{ STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)"},
{ STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)", 0},
#include "tbl/vrt_stv_var.h"

{ STRINGS, STRING, "upper", "VRT_UpperLowerStrands(ctx, \vT, 1)" },
{ STRINGS, STRING, "lower", "VRT_UpperLowerStrands(ctx, \vT, 0)" },
{ STRINGS, STRING, "upper", "VRT_UpperLowerStrands(ctx, \vT, 1)", 1 },
{ STRINGS, STRING, "lower", "VRT_UpperLowerStrands(ctx, \vT, 0)", 1 },

{ NULL, NULL, NULL, NULL},
};
Expand Down Expand Up @@ -859,6 +866,12 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
(*e)->fmt = STRINGS;
(*e)->nstr = 1;
}
if (vm->func) {
ExpectErr(tl, '(');
vcc_NextToken(tl);
ExpectErr(tl, ')');
vcc_NextToken(tl);
}
}
}

Expand Down

0 comments on commit 67ea0c8

Please sign in to comment.