Commit b295aab2 authored by Toby Allen's avatar Toby Allen Committed by Matt Holt

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

* Check errors directive only has 1 argument

* Added Tests
parent 448edcca
...@@ -123,6 +123,10 @@ func errorsParse(c *caddy.Controller) (*ErrorHandler, error) { ...@@ -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 // Configuration may be in a block
err := optionalBlock() err := optionalBlock()
if err != nil { if err != nil {
......
...@@ -179,6 +179,11 @@ func TestErrorsParse(t *testing.T) { ...@@ -179,6 +179,11 @@ func TestErrorsParse(t *testing.T) {
* generic_error.html * generic_error.html
* generic_error.html * generic_error.html
}`, true, ErrorHandler{ErrorPages: map[int]string{}, Log: &httpserver.Logger{}}}, }`, 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 { for i, test := range tests {
......
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