|
@ -54,24 +54,24 @@ func parseTagsHeader(tags string) (map[string]string, error) { |
|
|
return parsedTags, nil |
|
|
return parsedTags, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func validateTags(tags map[string]string) error { |
|
|
|
|
|
|
|
|
func ValidateTags(tags map[string]string) error { |
|
|
if len(tags) > 10 { |
|
|
if len(tags) > 10 { |
|
|
return fmt.Errorf("validate tags: %d tags more than 10", len(tags)) |
|
|
return fmt.Errorf("validate tags: %d tags more than 10", len(tags)) |
|
|
} |
|
|
} |
|
|
for k, v := range tags { |
|
|
for k, v := range tags { |
|
|
if len(k) > 128 { |
|
|
if len(k) > 128 { |
|
|
return fmt.Errorf("validate tags: tag key %s longer than 128", k) |
|
|
|
|
|
|
|
|
return fmt.Errorf("validate tags: tag key longer than 128") |
|
|
} |
|
|
} |
|
|
validateKey, err := regexp.MatchString(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`, k) |
|
|
validateKey, err := regexp.MatchString(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`, k) |
|
|
if !validateKey && err != nil { |
|
|
|
|
|
return fmt.Errorf("validate tags key %s error %w ", k, err) |
|
|
|
|
|
|
|
|
if !validateKey || err != nil { |
|
|
|
|
|
return fmt.Errorf("validate tags key %s error, incorrect key", k) |
|
|
} |
|
|
} |
|
|
if len(v) > 256 { |
|
|
if len(v) > 256 { |
|
|
return fmt.Errorf("validate tags: tag value %s longer than 256", v) |
|
|
|
|
|
|
|
|
return fmt.Errorf("validate tags: tag value longer than 256") |
|
|
} |
|
|
} |
|
|
validateValue, err := regexp.MatchString(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`, v) |
|
|
validateValue, err := regexp.MatchString(`^([\p{L}\p{Z}\p{N}_.:/=+\-@]*)$`, v) |
|
|
if !validateValue && err != nil { |
|
|
|
|
|
return fmt.Errorf("validate tags value %s error %w ", v, err) |
|
|
|
|
|
|
|
|
if !validateValue || err != nil { |
|
|
|
|
|
return fmt.Errorf("validate tags value %s error, incorrect value", v) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|