Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
99d13d21
Commit
99d13d21
authored
Aug 05, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add STRING.upper and STRING.lower
Relevant for #3023
parent
1e4b687b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
1 deletion
+97
-1
cache_vrt.c
bin/varnishd/cache/cache_vrt.c
+53
-0
v00058.vtc
bin/varnishtest/tests/v00058.vtc
+33
-0
vrt.h
include/vrt.h
+2
-0
vcc_expr.c
lib/libvcc/vcc_expr.c
+9
-1
No files found.
bin/varnishd/cache/cache_vrt.c
View file @
99d13d21
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
#include "cache_objhead.h"
#include "cache_objhead.h"
#include "vav.h"
#include "vav.h"
#include "vcl.h"
#include "vcl.h"
#include "vct.h"
#include "vrt_obj.h"
#include "vrt_obj.h"
#include "vsa.h"
#include "vsa.h"
#include "vtcp.h"
#include "vtcp.h"
...
@@ -183,6 +184,7 @@ VPI_BundleStrands(int n, struct strands *s, char const **d, const char *f, ...)
...
@@ -183,6 +184,7 @@ VPI_BundleStrands(int n, struct strands *s, char const **d, const char *f, ...)
{
{
va_list
ap
;
va_list
ap
;
assert
(
n
>
0
);
s
->
n
=
n
;
s
->
n
=
n
;
s
->
p
=
d
;
s
->
p
=
d
;
*
d
++
=
f
;
*
d
++
=
f
;
...
@@ -480,6 +482,57 @@ VRT_CollectStrands(VRT_CTX, VCL_STRANDS s)
...
@@ -480,6 +482,57 @@ VRT_CollectStrands(VRT_CTX, VCL_STRANDS s)
return
(
b
);
return
(
b
);
}
}
/*--------------------------------------------------------------------
* upper/lower-case STRANDS (onto workspace)
*/
#include <stdio.h>
VCL_STRING
VRT_UpperLowerStrands
(
VRT_CTX
,
VCL_STRANDS
s
,
int
up
)
{
unsigned
u
;
char
*
b
,
*
e
,
*
r
;
const
char
*
p
,
*
q
=
NULL
;
int
i
,
copy
=
0
;
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
CHECK_OBJ_NOTNULL
(
ctx
->
ws
,
WS_MAGIC
);
AN
(
s
);
u
=
WS_ReserveAll
(
ctx
->
ws
);
r
=
b
=
WS_Front
(
ctx
->
ws
);
e
=
b
+
u
;
for
(
i
=
0
;
i
<
s
->
n
;
i
++
)
{
if
(
s
->
p
[
i
]
==
NULL
||
s
->
p
[
i
][
0
]
==
'\0'
)
continue
;
if
(
q
!=
NULL
)
copy
=
1
;
p
=
q
=
s
->
p
[
i
];
for
(
p
=
q
=
s
->
p
[
i
];
*
p
!=
'\0'
;
p
++
)
{
if
((
up
&&
vct_islower
(
*
p
))
||
(
!
up
&&
vct_isupper
(
*
p
)))
{
*
b
++
=
*
p
^
0x20
;
copy
=
1
;
}
else
{
*
b
++
=
*
p
;
}
if
(
b
==
e
)
{
WS_Release
(
ctx
->
ws
,
0
);
VRT_fail
(
ctx
,
"Workspace overflow"
);
return
(
NULL
);
}
}
}
if
(
!
copy
)
{
WS_Release
(
ctx
->
ws
,
0
);
return
(
q
);
}
*
b
++
=
'\0'
;
assert
(
b
<=
e
);
WS_ReleaseP
(
ctx
->
ws
,
b
);
return
(
r
);
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
VCL_VOID
VCL_VOID
...
...
bin/varnishtest/tests/v00058.vtc
View file @
99d13d21
...
@@ -174,3 +174,36 @@ client c1 {
...
@@ -174,3 +174,36 @@ client c1 {
varnish v1 -expect client_resp_500 == 1
varnish v1 -expect client_resp_500 == 1
varnish v1 -expect ws_client_overflow == 2
varnish v1 -expect ws_client_overflow == 2
# Test $STRINGS.{upper|lower}
server s1 {
rxreq
txresp
} -start
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;
}
}
client c1 {
txreq -url /foo
rxresp
expect resp.http.l-proto == "http/1.1"
expect resp.http.u-proto == "HTTP/1.1"
expect resp.http.l-req == "/foo"
expect resp.http.u-req == "/FOO"
expect resp.http.l-mod == "/foobar"
expect resp.http.u-mod == "/FOOBAR"
expect resp.http.uu-mod == "/FOOBAR"
expect resp.http.ul-mod == "/foobar"
} -run
include/vrt.h
View file @
99d13d21
...
@@ -52,6 +52,7 @@
...
@@ -52,6 +52,7 @@
* binary/load-time compatible, increment MAJOR version
* binary/load-time compatible, increment MAJOR version
*
*
* unreleased (planned for 2019-09-15)
* unreleased (planned for 2019-09-15)
* VRT_UpperLowerStrands added.
* VRT_synth_page now takes STRANDS argument
* VRT_synth_page now takes STRANDS argument
* VRT_hashdata() now takes STRANDS argument
* VRT_hashdata() now takes STRANDS argument
* VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added.
* VCL_BOOL VRT_Strands2Bool(VCL_STRANDS) added.
...
@@ -538,6 +539,7 @@ VCL_BOOL VRT_Strands2Bool(VCL_STRANDS);
...
@@ -538,6 +539,7 @@ VCL_BOOL VRT_Strands2Bool(VCL_STRANDS);
char
*
VRT_Strands
(
char
*
,
size_t
,
VCL_STRANDS
);
char
*
VRT_Strands
(
char
*
,
size_t
,
VCL_STRANDS
);
VCL_STRING
VRT_StrandsWS
(
struct
ws
*
,
const
char
*
,
VCL_STRANDS
);
VCL_STRING
VRT_StrandsWS
(
struct
ws
*
,
const
char
*
,
VCL_STRANDS
);
VCL_STRING
VRT_CollectStrands
(
VRT_CTX
,
VCL_STRANDS
);
VCL_STRING
VRT_CollectStrands
(
VRT_CTX
,
VCL_STRANDS
);
VCL_STRING
VRT_UpperLowerStrands
(
VRT_CTX
,
VCL_STRANDS
s
,
int
up
);
VCL_STRING
VRT_BACKEND_string
(
VCL_BACKEND
);
VCL_STRING
VRT_BACKEND_string
(
VCL_BACKEND
);
VCL_STRING
VRT_BOOL_string
(
VCL_BOOL
);
VCL_STRING
VRT_BOOL_string
(
VCL_BOOL
);
...
...
lib/libvcc/vcc_expr.c
View file @
99d13d21
...
@@ -803,7 +803,7 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
...
@@ -803,7 +803,7 @@ vcc_expr5(struct vcc *tl, struct expr **e, vcc_type_t fmt)
/*--------------------------------------------------------------------
/*--------------------------------------------------------------------
* SYNTAX:
* SYNTAX:
* Expr4:
* Expr4:
* Expr5
* Expr5
[ '.' type_method() ]*
*/
*/
static
const
struct
vcc_methods
{
static
const
struct
vcc_methods
{
...
@@ -818,6 +818,9 @@ static const struct vcc_methods {
...
@@ -818,6 +818,9 @@ static const struct vcc_methods {
{ STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)"},
{ STEVEDORE, vtype, #nm, "VRT_stevedore_" #nm "(\v1)"},
#include "tbl/vrt_stv_var.h"
#include "tbl/vrt_stv_var.h"
{
STRINGS
,
STRING
,
"upper"
,
"VRT_UpperLowerStrands(ctx,
\v
T, 1)"
},
{
STRINGS
,
STRING
,
"lower"
,
"VRT_UpperLowerStrands(ctx,
\v
T, 0)"
},
{
NULL
,
NULL
,
NULL
,
NULL
},
{
NULL
,
NULL
,
NULL
,
NULL
},
};
};
...
@@ -851,6 +854,11 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
...
@@ -851,6 +854,11 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
}
}
vcc_NextToken
(
tl
);
vcc_NextToken
(
tl
);
*
e
=
vcc_expr_edit
(
tl
,
vm
->
type_to
,
vm
->
impl
,
*
e
,
NULL
);
*
e
=
vcc_expr_edit
(
tl
,
vm
->
type_to
,
vm
->
impl
,
*
e
,
NULL
);
ERRCHK
(
tl
);
if
((
*
e
)
->
fmt
==
STRING
)
{
(
*
e
)
->
fmt
=
STRINGS
;
(
*
e
)
->
nstr
=
1
;
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment