@marcel91200 / caddy Mirror · read-only / commits / a2dae1d4
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 14, 05:15 UTC

templates: Fix front matter closing fence search

This makes it choose first matching closing fence instead of last one, which could appear in document body.

Matthew Holt committed Jul 8, 2020 at 16:46 UTC a2dae1d43fcfb08a4b748302502874234d7d64af
2 files changed +12
modules/caddyhttp/templates/frontmatter.go
+1
@@ -56,6 +56,7 @@ func extractFrontMatter(input string) (map[string]interface{}, string, error) {
56 if index >= 0 {
57 fmEndFenceStart = index
58 fmEndFence = fence
59 + break
60 }
61 }
62 if fmEndFenceStart < 0 {
modules/caddyhttp/templates/tplcontext_test.go
+11
@@ -316,6 +316,17 @@ title: Welcome
316 expect: `Welcome`,
317 body: "\n### Test",
318 },
319 + {
320 + // yaml with non-fence '...' line after closing fence (i.e. first matching closing fence should be used)
321 + input: `---
322 +title: Welcome
323 +---
324 +### Test
325 +...
326 +yeah`,
327 + expect: `Welcome`,
328 + body: "\n### Test\n...\nyeah",
329 + },
330 {
331 // toml
332 input: `+++