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 --- .../import_args_snippet_env_placeholder.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 caddytest/integration/caddyfile_adapt/import_args_snippet_env_placeholder.txt (limited to 'caddytest/integration/caddyfile_adapt/import_args_snippet_env_placeholder.txt') diff --git a/caddytest/integration/caddyfile_adapt/import_args_snippet_env_placeholder.txt b/caddytest/integration/caddyfile_adapt/import_args_snippet_env_placeholder.txt new file mode 100644 index 0000000..1bc907e --- /dev/null +++ b/caddytest/integration/caddyfile_adapt/import_args_snippet_env_placeholder.txt @@ -0,0 +1,31 @@ +(foo) { + respond {env.FOO} +} + +:80 { + import foo +} +---------- +{ + "apps": { + "http": { + "servers": { + "srv0": { + "listen": [ + ":80" + ], + "routes": [ + { + "handle": [ + { + "body": "{env.FOO}", + "handler": "static_response" + } + ] + } + ] + } + } + } + } +} \ No newline at end of file -- cgit v1.2.3