Commit 702dec06 authored by Tw's avatar Tw

log: only allow new roller related options in a block

fix issue #1529
Signed-off-by: default avatarTw <tw19881113@gmail.com>
parent 8d1da68b
...@@ -41,12 +41,13 @@ func logParse(c *caddy.Controller) ([]*Rule, error) { ...@@ -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
} }
} }
......
...@@ -205,6 +205,8 @@ func TestLogParse(t *testing.T) { ...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment