mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-23 22:27:38 -05:00
Merge pull request #1583 from tw4452852/1529
log: only allow new roller related options in a block
This commit is contained in:
commit
6b66b19deb
2 changed files with 9 additions and 6 deletions
|
@ -41,12 +41,13 @@ func logParse(c *caddy.Controller) ([]*Rule, error) {
|
|||
}
|
||||
where := c.Val()
|
||||
|
||||
if httpserver.IsLogRollerSubdirective(what) {
|
||||
var err error
|
||||
err = httpserver.ParseRoller(logRoller, what, where)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// only support roller related options inside a block
|
||||
if !httpserver.IsLogRollerSubdirective(what) {
|
||||
return nil, c.ArgErr()
|
||||
}
|
||||
|
||||
if err := httpserver.ParseRoller(logRoller, what, where); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,6 +205,8 @@ func TestLogParse(t *testing.T) {
|
|||
Format: "{when}",
|
||||
}},
|
||||
}}},
|
||||
{`log access.log { rotate_size }`, true, nil},
|
||||
{`log access.log { invalid_option 1 }`, true, nil},
|
||||
}
|
||||
for i, test := range tests {
|
||||
c := caddy.NewTestController("http", test.inputLogRules)
|
||||
|
|
Loading…
Reference in a new issue