mirror of
https://github.com/caddyserver/caddy.git
synced 2025-10-19 07:43:17 +00:00
caddyfile: Prevent bad block opening tokens (#4655)
* caddyfile: Prevent bad block opening tokens * Clarifying comments
This commit is contained in:
parent
c9b5e7f77b
commit
134b805644
3 changed files with 77 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue