@marcel91200 / caddy Mirror · read-only / commits / e9d290de
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 17:15 UTC

caddyconfig: Fix indentation of multiline strings in fmt (#7425) (#7433)

Paulo Henrique committed Jan 13, 2026 at 17:22 UTC e9d290de2f349d774127b46670c086588bcaf5b0
2 files changed +21
caddyconfig/caddyfile/formatter.go
+10
@@ -18,6 +18,7 @@ import (
18 "bytes"
19 "io"
20 "slices"
21 + "strings"
22 "unicode"
23 )
24
@@ -209,6 +210,15 @@ func Format(input []byte) []byte {
210 }
211 }
212
213 + if strings.Contains(quotes, "`") {
214 + if ch == '`' && space && !beginningOfLine {
215 + write(' ')
216 + }
217 + write(ch)
218 + space = false
219 + continue
220 + }
221 +
222 if unicode.IsSpace(ch) {
223 space = true
224 heredocEscaped = false
caddyconfig/caddyfile/formatter_test.go
+11
@@ -464,6 +464,17 @@ block2 {
464 }
465 `,
466 },
467 + {
468 + description: "issue #7425: multiline backticked string indentation",
469 + input: `https://localhost:8953 {
470 + respond ` + "`" + `Here are some random numbers:
471 +
472 +{{randNumeric 16}}
473 +
474 +Hope this helps.` + "`" + `
475 +}`,
476 + expect: "https://localhost:8953 {\n\trespond `Here are some random numbers:\n\n{{randNumeric 16}}\n\nHope this helps.`\n}",
477 + },
478 } {
479 // the formatter should output a trailing newline,
480 // even if the tests aren't written to expect that