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
Fix snippet nesting bug
Matthew Holt committed
Aug 21, 2019 at 11:26 UTC
b2aa679c33f63ebec5bc1a21bca01f345dffebdd
1 file changed
+5
-6
caddyconfig/caddyfile/parse.go
+5
-6
@@ -459,23 +459,22 @@ func (p *parser) snippetTokens() ([]Token, error) {
459
if err != nil {
460
return nil, err
461
}
462
- count := 1
462
+ nesting := 1 // count our own nesting in snippets
463
tokens := []Token{}
464
for p.Next() {
465
if p.Val() == "}" {
466
- count--
467
- if count == 0 {
466
+ nesting--
467
+ if nesting == 0 {
468
break
469
}
470
}
471
if p.Val() == "{" {
472
- p.nesting++
473
- count++
472
+ nesting++
473
}
474
tokens = append(tokens, p.tokens[p.cursor])
475
}
476
// make sure we're matched up
478
- if count != 0 {
477
+ if nesting != 0 {
478
return nil, p.SyntaxErr("}")
479
}
480
return tokens, nil