Skip to content
Permalink
Browse files

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 67ea0c83c3eb7df9e971fa8011cc0cbe2814ca57
Showing with 25 additions and 12 deletions.
  1. +8 −8 bin/varnishtest/tests/v00058.vtc
  2. +17 −4 lib/libvcc/vcc_expr.c
@@ -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();
}
}

@@ -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},
};
@@ -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);
}
}
}

0 comments on commit 67ea0c8

Please sign in to comment.
You can’t perform that action at this time.