From b2aa679c33f63ebec5bc1a21bca01f345dffebdd Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 21 Aug 2019 11:26:48 -0600 Subject: Fix snippet nesting bug --- caddyconfig/caddyfile/parse.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'caddyconfig') diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go index e5b25fc..cc7ed25 100755 --- a/caddyconfig/caddyfile/parse.go +++ b/caddyconfig/caddyfile/parse.go @@ -459,23 +459,22 @@ func (p *parser) snippetTokens() ([]Token, error) { if err != nil { return nil, err } - count := 1 + nesting := 1 // count our own nesting in snippets tokens := []Token{} for p.Next() { if p.Val() == "}" { - count-- - if count == 0 { + nesting-- + if nesting == 0 { break } } if p.Val() == "{" { - p.nesting++ - count++ + nesting++ } tokens = append(tokens, p.tokens[p.cursor]) } // make sure we're matched up - if count != 0 { + if nesting != 0 { return nil, p.SyntaxErr("}") } return tokens, nil -- cgit v1.2.3