Skip to content

Commit

Permalink
Check that / prefix present before split.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbobrovskyi committed Oct 6, 2024
1 parent ee7b2d9 commit bc26d4e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/jobframework/webhook/defaulter.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ func (h *losslessDefaulter) Handle(ctx context.Context, req admission.Request) a
}

func fieldExistsByJSONPath(object interface{}, path string) bool {
// Invalid path. For more information, see https://datatracker.ietf.org/doc/html/rfc6901#section-3.
if !strings.HasPrefix(path, "/") {
return false
}
pathParts := strings.Split(path, "/")
// Invalid path. For more information, see https://jsonpatch.com/.
if len(pathParts) < 2 || len(pathParts) > 0 && pathParts[0] != "" {
if len(pathParts) < 2 {
return false
}
return fieldExistsByJSONPathHelper(object, pathParts[1:])
Expand Down

0 comments on commit bc26d4e

Please sign in to comment.