diff --git a/caddyhttp/errors/setup.go b/caddyhttp/errors/setup.go index 90a5fd25d..bcda1c8b3 100644 --- a/caddyhttp/errors/setup.go +++ b/caddyhttp/errors/setup.go @@ -123,6 +123,10 @@ func errorsParse(c *caddy.Controller) (*ErrorHandler, error) { } } + if len(args) > 1 { + return handler, c.Errf("Only 1 Argument expected for errors directive") + } + // Configuration may be in a block err := optionalBlock() if err != nil { diff --git a/caddyhttp/errors/setup_test.go b/caddyhttp/errors/setup_test.go index 0c83055f5..b13aecf00 100644 --- a/caddyhttp/errors/setup_test.go +++ b/caddyhttp/errors/setup_test.go @@ -179,6 +179,11 @@ func TestErrorsParse(t *testing.T) { * generic_error.html * generic_error.html }`, true, ErrorHandler{ErrorPages: map[int]string{}, Log: &httpserver.Logger{}}}, + {`errors /path error.txt { + 404 + }`, true, ErrorHandler{ErrorPages: map[int]string{}, Log: &httpserver.Logger{}}}, + + {`errors /path error.txt`, true, ErrorHandler{ErrorPages: map[int]string{}, Log: &httpserver.Logger{}}}, } for i, test := range tests {