Browse Source
caddyfile: Fix bug with Delete
It now will delete the current token even if it is the last one
master
Matthew Holt
6 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
2 changed files with
3 additions and
2 deletions
-
caddyconfig/caddyfile/dispenser.go
-
caddyconfig/httpcaddyfile/directives.go
|
@ -339,7 +339,7 @@ func (d *Dispenser) Errf(format string, args ...interface{}) error { |
|
|
// array will become apparent (or worse, hide from you like they
|
|
|
// array will become apparent (or worse, hide from you like they
|
|
|
// did me for 3 and a half freaking hours late one night).
|
|
|
// did me for 3 and a half freaking hours late one night).
|
|
|
func (d *Dispenser) Delete() []Token { |
|
|
func (d *Dispenser) Delete() []Token { |
|
|
if d.cursor >= 0 && d.cursor < len(d.tokens)-1 { |
|
|
if d.cursor >= 0 && d.cursor <= len(d.tokens)-1 { |
|
|
d.tokens = append(d.tokens[:d.cursor], d.tokens[d.cursor+1:]...) |
|
|
d.tokens = append(d.tokens[:d.cursor], d.tokens[d.cursor+1:]...) |
|
|
d.cursor-- |
|
|
d.cursor-- |
|
|
} |
|
|
} |
|
|
|
@ -64,7 +64,8 @@ func RegisterHandlerDirective(dir string, setupFunc UnmarshalHandlerFunc) { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
if ok { |
|
|
if ok { |
|
|
h.Dispenser.Delete() // strip matcher token
|
|
|
tokens := h.Dispenser.Delete() // strip matcher token
|
|
|
|
|
|
h.Dispenser = caddyfile.NewDispenser(tokens) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
h.Dispenser.Reset() // pretend this lookahead never happened
|
|
|
h.Dispenser.Reset() // pretend this lookahead never happened
|
|
|