diff options
author | Francis Lavoie <lavofr@gmail.com> | 2022-03-23 14:34:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 12:34:13 -0600 |
commit | 134b8056444d8f417c0eb4163809f9659ffc3317 (patch) | |
tree | 62bc3fc0af4af24926730f63af56740943e3f36f /caddyconfig/caddyfile/parse.go | |
parent | c9b5e7f77b8aac7334d81c552c583af81ba1c400 (diff) |
caddyfile: Prevent bad block opening tokens (#4655)
* caddyfile: Prevent bad block opening tokens
* Clarifying comments
Diffstat (limited to 'caddyconfig/caddyfile/parse.go')
-rwxr-xr-x | caddyconfig/caddyfile/parse.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/caddyconfig/caddyfile/parse.go b/caddyconfig/caddyfile/parse.go index 1e694f9..b463238 100755 --- a/caddyconfig/caddyfile/parse.go +++ b/caddyconfig/caddyfile/parse.go @@ -494,6 +494,13 @@ func (p *parser) directive() error { for p.Next() { if p.Val() == "{" { p.nesting++ + if !p.isNextOnNewLine() && p.Token().wasQuoted == 0 { + return p.Err("Unexpected next token after '{' on same line") + } + } else if p.Val() == "{}" { + if p.isNextOnNewLine() && p.Token().wasQuoted == 0 { + return p.Err("Unexpected '{}' at end of line") + } } else if p.isNewLine() && p.nesting == 0 { p.cursor-- // read too far break |