From 702dec064740324418944065ad6870bd2c4a8186 Mon Sep 17 00:00:00 2001 From: Tw Date: Mon, 17 Apr 2017 16:51:37 +0800 Subject: [PATCH] log: only allow new roller related options in a block fix issue #1529 Signed-off-by: Tw --- caddyhttp/log/setup.go | 13 +++++++------ caddyhttp/log/setup_test.go | 2 ++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/caddyhttp/log/setup.go b/caddyhttp/log/setup.go index 2366aec0..47b25978 100644 --- a/caddyhttp/log/setup.go +++ b/caddyhttp/log/setup.go @@ -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 } } diff --git a/caddyhttp/log/setup_test.go b/caddyhttp/log/setup_test.go index f56749c5..d248f394 100644 --- a/caddyhttp/log/setup_test.go +++ b/caddyhttp/log/setup_test.go @@ -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)