Skip to content

Commit

Permalink
fix: reserve IDs starting and ending with '__' for internal use
Browse files Browse the repository at this point in the history
  • Loading branch information
garethgeorge committed May 19, 2024
1 parent fcdf07d commit 711064f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/config/validationutil/validationutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"regexp"
"strings"
)

var (
Expand All @@ -26,6 +27,9 @@ func SanitizeID(id string) string {
// It returns an error if the ID contains invalid characters, is empty, or is too long.
// The maxLen parameter is the maximum length of the ID. If maxLen is 0, the ID length is not checked.
func ValidateID(id string, maxLen int) error {
if strings.HasPrefix(id, "__") && strings.HasSuffix(id, "__") {
return errors.New("IDs starting and ending with '__' are reserved by backrest")
}
if !idRegex.MatchString(id) {
return ErrInvalidChars
}
Expand Down

0 comments on commit 711064f

Please sign in to comment.