diff options
author | Matthew Holt <[email protected]> | 2019-08-21 11:26:48 -0600 |
---|---|---|
committer | Matthew Holt <[email protected]> | 2019-08-21 11:26:48 -0600 |
commit | b2aa679c33f63ebec5bc1a21bca01f345dffebdd (patch) | |
tree | 3e75e6f59047bb967c52915e1e75aee6ad67c0ea /caddyconfig/caddyfile/parse.go | |
parent | fa334c4bdf1c5e6c0014a36460d329c8d22cafb0 (diff) | |
download | caddy-b2aa679c33f63ebec5bc1a21bca01f345dffebdd.tar.gz caddy-b2aa679c33f63ebec5bc1a21bca01f345dffebdd.zip |
Fix snippet nesting bug
Diffstat (limited to 'caddyconfig/caddyfile/parse.go')
-rwxr-xr-x | caddyconfig/caddyfile/parse.go | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go index e5b25fc3a..cc7ed25db 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 |