Skip to content

Commit

Permalink
Merge pull request #1635 from kylewuolle/fix-role-parsing
Browse files Browse the repository at this point in the history
Fix role parsing in golang 1.17+
  • Loading branch information
justincormack authored May 31, 2022
2 parents 0154426 + efc35b0 commit bc25fff
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion server/handlers/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/hex"
"encoding/json"
"io"
"mime"
"net/http"
"strings"

Expand Down Expand Up @@ -72,7 +73,12 @@ func atomicUpdateHandler(ctx context.Context, w http.ResponseWriter, r *http.Req
if err == io.EOF {
break
}
role := data.RoleName(strings.TrimSuffix(part.FileName(), ".json"))
_, params, err := mime.ParseMediaType(part.Header.Get("Content-Disposition"))
if err != nil {
logger.Infof("400 POST error parsing Content-Disposition header: %s", err)
return errors.ErrNoFilename.WithDetail(nil)
}
role := data.RoleName(strings.TrimSuffix(params["filename"], ".json"))
if role.String() == "" {
logger.Info("400 POST empty role")
return errors.ErrNoFilename.WithDetail(nil)
Expand Down

0 comments on commit bc25fff

Please sign in to comment.