mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-28 04:45:56 +03:00
errors: Return parse error if more than one argument (#2472)
* Check errors directive only has 1 argument * Added Tests
This commit is contained in:
parent
448edcca8e
commit
b295aab2d8
2 changed files with 9 additions and 0 deletions
|
@ -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) {
|
||||||
* 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 {
|
||||||
|
|
Loading…
Reference in a new issue