caddyfile: advance cursor for claimed token in NewFromNextTokens() (#2971)

When we append a token to the new dispenser, we need to consume it in the parent, too; otherwise it gets scanned twice, which in this case messed up the nesting count which got decremented once too many times.
This commit is contained in:
Zaq? Wiedmann 2020-01-09 19:48:15 -08:00 committed by Matt Holt
parent 871abf1053
commit 3dcc34d341

View file

@ -275,6 +275,10 @@ func (d *Dispenser) NewFromNextTokens() *Dispenser {
if openedBlock {
// include closing brace accordingly
tkns = append(tkns, d.Token())
// since NewFromNextTokens is intended to consume the entire
// directive, we must call Next() here and consume the closing
// curly brace
d.Next()
}
return NewDispenser(tkns)
}