-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vcl: Allow header names to be quoted
Because we funnel HTTP header names through the symbol table they have to be valid VCL identifiers. It means that we can't support all valid header names, which are tokens in the HTTP grammar. To finally close this loophole without the help of a VMOD we allow header names to be quoted: req.http.regular-header req.http."quoted.header" However we don't want to allow any component of a symbol to be quoted: req."http".we-dont-want-this So we teach the symbol table that wildcard symbols may be quoted. There used to be several use cases for wildcards but it is now limited to HTTP headers. Refs #3246 Refs #3379
- Loading branch information
Showing
4 changed files
with
102 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
varnishtest "Non-symbolic HTTP headers names" | ||
|
||
varnish v1 -errvcl "Invalid character '\\n' in header name" { | ||
backend be none; | ||
sub vcl_recv { | ||
set req.http.{"line | ||
break"} = "invalid"; | ||
} | ||
} | ||
|
||
varnish v1 -errvcl "Expected '=' got '.'" { | ||
backend be none; | ||
sub vcl_recv { | ||
set req."http".wrong-quote = "invalid"; | ||
} | ||
} | ||
|
||
varnish v1 -syntax 4.0 -errvcl "Quoted headers are available for VCL >= 4.1" { | ||
backend be none; | ||
sub vcl_recv { | ||
set req.http."quoted" = "invalid"; | ||
} | ||
} | ||
|
||
varnish v1 -vcl { | ||
import std; | ||
backend be none; | ||
sub vcl_recv { | ||
std.collect(req.http."..."); | ||
return (synth(200)); | ||
} | ||
sub vcl_synth { | ||
set resp.http."123" = "456"; | ||
set resp.http."456" = resp.http."123"; | ||
set resp.http.{"!!!"} = "???"; | ||
set resp.http."""resp.http.foo""" = "bar"; | ||
set resp.http.bar = resp.http."resp.http.foo".upper(); | ||
set resp.http."..." = req.http."..."; | ||
} | ||
} -start | ||
|
||
client c1 { | ||
txreq -hdr "...: a" -hdr "...: b" | ||
rxresp | ||
expect resp.http.123 == 456 | ||
expect resp.http.456 == 456 | ||
expect resp.http.!!! == ??? | ||
expect resp.http.resp.http.foo == bar | ||
expect resp.http.bar == BAR | ||
expect resp.http.... == "a, b" | ||
} -run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters