aboutsummaryrefslogtreecommitdiffhomepage
path: root/caddyconfig/caddyfile/parse.go
diff options
context:
space:
mode:
authorFrancis Lavoie <[email protected]>2024-05-23 22:06:16 -0400
committerGitHub <[email protected]>2024-05-23 20:06:16 -0600
commitf6d2c293e752254769efe21c8d06a16ebad4845e (patch)
tree8ae8e566f0bddfe9356d84bf073c2bb63fac99a2 /caddyconfig/caddyfile/parse.go
parent2ce5c6526938b604586c987fa3d31117721e40a6 (diff)
downloadcaddy-f6d2c293e752254769efe21c8d06a16ebad4845e.tar.gz
caddy-f6d2c293e752254769efe21c8d06a16ebad4845e.zip
caddyfile: Reject global request matchers earlier (#6339)
Diffstat (limited to 'caddyconfig/caddyfile/parse.go')
-rw-r--r--caddyconfig/caddyfile/parse.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go
index a865b70df..17b0ca8e2 100644
--- a/caddyconfig/caddyfile/parse.go
+++ b/caddyconfig/caddyfile/parse.go
@@ -214,7 +214,12 @@ func (p *parser) addresses() error {
value := p.Val()
token := p.Token()
- // special case: import directive replaces tokens during parse-time
+ // Reject request matchers if trying to define them globally
+ if strings.HasPrefix(value, "@") {
+ return p.Errf("request matchers may not be defined globally, they must be in a site block; found %s", value)
+ }
+
+ // Special case: import directive replaces tokens during parse-time
if value == "import" && p.isNewLine() {
err := p.doImport(0)
if err != nil {