prettysunflower
7dedd1486c
Tests / test (./cmd/caddy/caddy, ~1.26.0, ubuntu-latest, 0, 1.26, linux) (push) Failing after 1m47s
Tests / test (s390x on IBM Z) (push) Has been skipped
Tests / goreleaser-check (push) Has been skipped
Cross-Build / build (~1.26.0, 1.26, aix) (push) Successful in 1m23s
Cross-Build / build (~1.26.0, 1.26, darwin) (push) Successful in 1m25s
Cross-Build / build (~1.26.0, 1.26, dragonfly) (push) Successful in 1m26s
Cross-Build / build (~1.26.0, 1.26, freebsd) (push) Successful in 1m25s
Cross-Build / build (~1.26.0, 1.26, illumos) (push) Successful in 1m44s
Cross-Build / build (~1.26.0, 1.26, linux) (push) Successful in 1m35s
Cross-Build / build (~1.26.0, 1.26, netbsd) (push) Successful in 2m32s
Cross-Build / build (~1.26.0, 1.26, openbsd) (push) Successful in 2m18s
Cross-Build / build (~1.26.0, 1.26, solaris) (push) Successful in 1m26s
Cross-Build / build (~1.26.0, 1.26, windows) (push) Successful in 1m48s
Lint / lint (ubuntu-latest, linux) (push) Successful in 2m34s
Lint / govulncheck (push) Successful in 2m38s
Lint / dependency-review (push) Failing after 1m29s
Tests / test (./cmd/caddy/caddy, ~1.26.0, macos-14, 0, 1.26, mac) (push) Has been cancelled
Tests / test (./cmd/caddy/caddy.exe, ~1.26.0, windows-latest, True, 1.26, windows) (push) Has been cancelled
Lint / lint (macos-14, mac) (push) Has been cancelled
Lint / lint (windows-latest, windows) (push) Has been cancelled
OpenSSF Scorecard supply-chain security / Scorecard analysis (push) Failing after 7m56s
fix(caddyfile): {block} in snippet ( #7558 )
...
* fix(caddyfile): {block} in snippet
Resolve issue #7557
So, here is the situation:
- Pull request #7206 included some changes to the doImport's function of
Caddyfile's parser. What it does is that if there is no token within a
block that follows the import, and the import contains `{block}`, then
the `{block}` token is discarded.
- After this pull request:
- Issue #7518 noticed that in cases that `{block}` was not imported,
a runtime error was raised due to the assumption that tokens were
always added to `tokensCopy` on every iteration of `importedTokens`.
This was fixed by pull request #7543 .
- Issue #7557 notices that {block} can be ignored when imported from a
certain file. There, it's again an issue with how the import works.
When `import snippets` is called, this import instruction doesn't
contains any nested blocks. And when the argument replacer that is
the `importedTokens` loop is called and finds `{block}`, it uses the
block from the file's import (which in this case is nothing),
`{block}` is erased, and unavailable when the import directive is
called for the imported snippet.
The changed in this commit addresses the second issue by checking before
replacing `{block}` if we're currently in a snippet definition, and
appending the `{block}` token to `tokensCopy` if we are.
With this changes, when importing those snippets, the `{block}` token
will be available to be replaced by the nested blocks in `tokensToAdd`
if needed, or erased if there are no nested blocks and `tokensToAdd` is empty.
Tests added in pull requests #7206 and #7543 passes with this new
implementation, confirming that unused `{block}` are accepted if nothing
is passed to `import`, as well as the other usual tests.
A new test was also added based on issue #7557 reporting, and also passes.
Signed-off-by: prettysunflower <me@prettysunflower.moe>
* caddyfile: add imported snippet block placeholder coverage
---------
Signed-off-by: prettysunflower <me@prettysunflower.moe>
Co-authored-by: Zen Dodd <mail@steadytao.com>
2026-04-15 02:58:53 -04:00
..
2025-10-03 14:05:46 -06:00
2025-08-04 16:22:25 -06:00
2025-08-22 15:09:25 -06:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2025-05-08 11:54:07 -06:00
2025-05-08 11:54:07 -06:00
2025-05-08 11:54:07 -06:00
2024-10-10 13:38:49 -06:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-09-30 10:55:03 -06:00
2024-02-21 00:37:40 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2024-02-21 00:37:40 +00:00
2026-03-28 13:07:21 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2025-06-06 11:46:39 -06:00
2024-05-01 07:43:05 -04:00
2024-02-21 00:37:40 +00:00
2024-04-13 06:49:55 -04:00
2024-11-05 09:35:32 -07:00
2024-02-21 00:37:40 +00:00
2024-12-10 16:48:02 -07:00
2024-08-30 09:01:37 -06:00
2024-02-21 00:37:40 +00:00
2026-03-03 23:30:49 -05:00
2026-03-03 23:30:49 -05:00
2026-03-03 23:30:49 -05:00
2024-10-07 17:39:47 -04:00
2024-02-21 00:37:40 +00:00
2024-10-07 17:39:47 -04:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-11-11 16:42:50 -07:00
2024-02-21 00:37:40 +00:00
2025-08-04 16:22:25 -06:00
2026-03-01 15:32:04 -05:00
2026-03-01 15:32:04 -05:00
2026-03-01 15:32:04 -05:00
2026-03-01 15:32:04 -05:00
2026-03-01 15:32:04 -05:00
2024-02-21 00:37:40 +00:00
2024-11-05 10:47:41 -07:00
2024-02-21 00:37:40 +00:00
2026-02-16 10:20:47 -07:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2025-07-14 14:55:00 -06:00
2025-01-07 22:48:06 -07:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2024-10-10 13:38:49 -06:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-04-16 22:26:18 +00:00
2025-08-22 21:29:34 +00:00
2024-06-14 11:27:51 -06:00
2026-04-15 02:58:53 -04:00
2026-03-03 13:16:21 -05:00
2025-09-12 20:29:09 +00:00
2025-09-12 20:29:09 +00:00
2024-06-14 11:27:51 -06:00
2025-08-22 21:29:34 +00:00
2024-06-14 11:27:51 -06:00
2024-06-14 11:27:51 -06:00
2025-06-30 23:58:16 +00:00
2024-05-13 17:38:18 +00:00
2024-02-21 00:37:40 +00:00
2025-06-30 23:58:16 +00:00
2024-03-05 17:03:59 -07:00
2024-03-05 16:24:32 -07:00
2024-04-16 22:26:18 +00:00
2024-02-21 00:37:40 +00:00
2024-05-11 13:31:44 +00:00
2024-03-05 16:24:32 -07:00
2026-04-10 17:09:12 -06:00
2024-04-16 22:26:18 +00:00
2025-10-16 05:08:53 +00:00
2024-04-16 22:26:18 +00:00
2024-04-16 22:26:18 +00:00
2024-04-16 22:26:18 +00:00
2026-02-23 16:04:45 -07:00
2024-11-11 16:42:50 -07:00
2024-04-16 22:26:18 +00:00
2024-10-10 13:38:49 -06:00
2025-06-30 23:58:16 +00:00
2024-05-30 07:32:17 -06:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-10-18 09:54:21 -06:00
2024-10-18 09:54:21 -06:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-12-02 08:06:38 -05:00
2024-12-03 05:44:49 -07:00
2024-02-21 00:37:40 +00:00
2024-12-03 05:44:49 -07:00
2024-12-03 05:44:49 -07:00
2024-12-03 05:44:49 -07:00
2024-12-02 08:06:38 -05:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2026-02-13 16:47:02 -05:00
2026-02-13 16:47:02 -05:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-04-23 07:12:57 -06:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-07-12 17:01:58 -04:00
2024-02-21 00:37:40 +00:00
2024-08-19 10:55:55 -06:00
2025-03-21 17:06:15 +00:00
2025-03-21 17:06:15 +00:00
2024-04-12 07:19:14 -06:00
2024-04-12 07:19:14 -06:00
2025-03-21 17:06:15 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-08-22 19:52:05 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2026-04-10 14:49:32 -06:00
2025-10-16 02:47:32 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-04-17 12:19:14 -06:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2026-02-15 09:04:59 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-04-13 21:31:43 -04:00
2024-04-13 21:31:43 -04:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-04-13 21:31:43 -04:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2026-03-26 14:41:34 -06:00
2026-03-26 14:41:34 -06:00
2024-04-13 21:31:43 -04:00
2025-04-18 11:44:23 -06:00
2024-12-24 08:58:40 -07:00
2024-02-26 00:13:48 +03:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2026-04-06 01:13:34 +03:00
2026-04-06 01:13:34 +03:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2024-02-21 00:37:40 +00:00
2025-06-09 08:18:36 -06:00
2025-06-09 08:18:36 -06:00
2025-06-09 08:18:36 -06:00
2025-06-09 08:18:36 -06:00
2025-06-09 08:18:36 -06:00
2025-06-09 08:18:36 -06:00
2026-04-06 01:13:34 +03:00
2024-02-21 00:37:40 +00:00
2025-06-30 23:58:16 +00:00
2025-10-03 14:05:46 -06:00
2025-10-03 14:05:46 -06:00
2025-06-30 23:58:16 +00:00
2025-06-30 23:58:16 +00:00
2025-10-03 14:05:46 -06:00
2025-06-30 23:58:16 +00:00
2024-04-13 21:31:43 -04:00
2024-04-13 21:31:43 -04:00
2024-02-21 00:37:40 +00:00
2025-06-30 23:58:16 +00:00
2024-02-21 00:37:40 +00:00
2024-03-22 02:23:42 +00:00
2024-02-21 00:37:40 +00:00
2024-10-02 07:31:58 -06:00