errors: Return parse error if more than one argument (#2472)

* Check errors directive only has 1 argument

* Added Tests
This commit is contained in:
Toby Allen 2019-03-04 19:00:28 +00:00 committed by Matt Holt
parent 448edcca8e
commit b295aab2d8
2 changed files with 9 additions and 0 deletions

View file

@ -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 {

View file

@ -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 {