From 483e31b9788f57b0a1adc153574878d0c7c4feb0 Mon Sep 17 00:00:00 2001 From: Thorkild Gregersen Date: Mon, 18 May 2020 21:01:04 +0200 Subject: templates: trim windows whitespace in SplitFrontMatter; fix #3386 (#3387) * add test case for SplitFrontMatter showing issue with windows newline * fix issue with windows newline when using SplitFrontMatter * Update modules/caddyhttp/templates/frontmatter.go Co-authored-by: Francis Lavoie * make it mere explicit what is trimmed from firstLine * Update modules/caddyhttp/templates/frontmatter.go Co-authored-by: Francis Lavoie Co-authored-by: Matt Holt --- modules/caddyhttp/templates/frontmatter.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'modules/caddyhttp/templates/frontmatter.go') diff --git a/modules/caddyhttp/templates/frontmatter.go b/modules/caddyhttp/templates/frontmatter.go index d6b6d0e..d781c7b 100644 --- a/modules/caddyhttp/templates/frontmatter.go +++ b/modules/caddyhttp/templates/frontmatter.go @@ -30,6 +30,9 @@ func extractFrontMatter(input string) (map[string]interface{}, string, error) { } firstLine := input[firstLineStart:firstLineEnd] + // ensure residue windows carriage return byte is removed + firstLine = strings.TrimSpace(firstLine) + // see what kind of front matter there is, if any var closingFence string var fmParser func([]byte) (map[string]interface{}, error) -- cgit v1.2.3