0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-01-06 22:40:31 -05:00

log: only allow new roller related options in a block

fix issue #1529

Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
Tw 2017-04-17 16:51:37 +08:00
parent 8d1da68b47
commit 702dec0647
2 changed files with 9 additions and 6 deletions

View file

@ -41,12 +41,13 @@ func logParse(c *caddy.Controller) ([]*Rule, error) {
} }
where := c.Val() where := c.Val()
if httpserver.IsLogRollerSubdirective(what) { // only support roller related options inside a block
var err error if !httpserver.IsLogRollerSubdirective(what) {
err = httpserver.ParseRoller(logRoller, what, where) return nil, c.ArgErr()
if err != nil { }
return nil, err
} if err := httpserver.ParseRoller(logRoller, what, where); err != nil {
return nil, err
} }
} }

View file

@ -205,6 +205,8 @@ func TestLogParse(t *testing.T) {
Format: "{when}", Format: "{when}",
}}, }},
}}}, }}},
{`log access.log { rotate_size }`, true, nil},
{`log access.log { invalid_option 1 }`, true, nil},
} }
for i, test := range tests { for i, test := range tests {
c := caddy.NewTestController("http", test.inputLogRules) c := caddy.NewTestController("http", test.inputLogRules)