mirror of
https://github.com/caddyserver/caddy.git
synced 2025-05-25 04:00:00 +08:00
admin: expect quoted ETags (#4879)
* expect quoted etags * admin: Minor refactor of etag facilities Co-authored-by: Matthew Holt <mholt@users.noreply.github.com>
This commit is contained in:
10
caddy.go
10
caddy.go
@ -145,8 +145,16 @@ func changeConfig(method, path string, input []byte, ifMatchHeader string, force
|
||||
defer currentCfgMu.Unlock()
|
||||
|
||||
if ifMatchHeader != "" {
|
||||
// expect the first and last character to be quotes
|
||||
if len(ifMatchHeader) < 2 || ifMatchHeader[0] != '"' || ifMatchHeader[len(ifMatchHeader)-1] != '"' {
|
||||
return APIError{
|
||||
HTTPStatus: http.StatusBadRequest,
|
||||
Err: fmt.Errorf("malformed If-Match header; expect quoted string"),
|
||||
}
|
||||
}
|
||||
|
||||
// read out the parts
|
||||
parts := strings.Fields(ifMatchHeader)
|
||||
parts := strings.Fields(ifMatchHeader[1 : len(ifMatchHeader)-1])
|
||||
if len(parts) != 2 {
|
||||
return APIError{
|
||||
HTTPStatus: http.StatusBadRequest,
|
||||
|
Reference in New Issue
Block a user