From a8d45277ca387ca4769fb4e881d242a5896cca5a Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 22 Apr 2021 20:29:04 -0400 Subject: caddyfile: Fix `import` replacing unrelated placeholders (#4129) * caddyfile: Fix `import` replacing unrelated placeholders See https://caddy.community/t/snippet-issue-works-outside-snippet/12231 So it turns out that `NewReplacer()` gives a replacer with some global defaults (like `{env.*}` and some system and time placeholders), which is not ideal when running `import` because we just want to replace `{args.*}` only, and nothing else. * caddyfile: Add test --- caddyconfig/caddyfile/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'caddyconfig/caddyfile') diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go index 52abf47..96491bb 100755 --- a/caddyconfig/caddyfile/parse.go +++ b/caddyconfig/caddyfile/parse.go @@ -321,7 +321,7 @@ func (p *parser) doImport() error { args := p.RemainingArgs() // add args to the replacer - repl := caddy.NewReplacer() + repl := caddy.NewEmptyReplacer() for index, arg := range args { repl.Set("args."+strconv.Itoa(index), arg) } -- cgit v1.2.3