From 3dcc34d3418d3ef5835eac512a52226e47727cfb Mon Sep 17 00:00:00 2001 From: Zaq? Wiedmann Date: Thu, 9 Jan 2020 19:48:15 -0800 Subject: 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. --- caddyconfig/caddyfile/dispenser.go | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'caddyconfig') diff --git a/caddyconfig/caddyfile/dispenser.go b/caddyconfig/caddyfile/dispenser.go index 6afbd77..5b90b73 100755 --- a/caddyconfig/caddyfile/dispenser.go +++ b/caddyconfig/caddyfile/dispenser.go @@ -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) } -- cgit v1.2.3