Skip to content

Commit 24bd39a

Browse files
committed
Update valiadation for annotation
1 parent 6ae2d8c commit 24bd39a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

internal/configs/annotations.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,7 @@ func parseAnnotations(ingEx *IngressEx, baseCfgParams *ConfigParams, isPlus bool
505505
}
506506

507507
if appRoot, exists := ingEx.Ingress.Annotations["nginx.org/app-root"]; exists {
508-
if !VerifyPath(appRoot) {
509-
nl.Errorf(l, "Ingress %s/%s: Invalid value nginx.org/app-root: got %q. Must start with '/'", ingEx.Ingress.GetNamespace(), ingEx.Ingress.GetName(), appRoot)
510-
} else {
511-
cfgParams.AppRoot = appRoot
512-
}
508+
cfgParams.AppRoot = appRoot
513509
}
514510

515511
if useClusterIP, exists, err := GetMapKeyAsBool(ingEx.Ingress.Annotations, UseClusterIPAnnotation, ingEx.Ingress); exists {

internal/k8s/validation.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ var (
363363
},
364364
appRootAnnotation: {
365365
validateAppRootAnnotation,
366+
validateRewriteTargetAnnotation,
366367
},
367368
}
368369
annotationNames = sortedAnnotationNames(annotationValidations)
@@ -394,9 +395,9 @@ func validateAppRootAnnotation(context *annotationValidationContext) field.Error
394395
return allErrs
395396
}
396397

397-
if !configs.VerifyPath(path) {
398-
allErrs = append(allErrs, field.Invalid(context.fieldPath, path, "path must start with '/' and must not include any special character, '{', '}', ';' or '$'"))
399-
return allErrs
398+
validPath := regexp.MustCompile(`^/[a-zA-Z0-9\-_./]*$`)
399+
if !validPath.MatchString(path) {
400+
allErrs = append(allErrs, field.Invalid(context.fieldPath, path, "contains invalid characters, only alphanumeric, hyphens, underscores, dots, and forward slashes are allowed"))
400401
}
401402

402403
// Ensure path doesn't end with /

0 commit comments

Comments
 (0)