Browse Source

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.
master
Zaq? Wiedmann 5 years ago
committed by Matt Holt
parent
commit
3dcc34d341
  1. 4
      caddyconfig/caddyfile/dispenser.go

4
caddyconfig/caddyfile/dispenser.go

@ -275,6 +275,10 @@ func (d *Dispenser) NewFromNextTokens() *Dispenser {
if openedBlock { if openedBlock {
// include closing brace accordingly // include closing brace accordingly
tkns = append(tkns, d.Token()) 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) return NewDispenser(tkns)
} }

Loading…
Cancel
Save