diff --git a/pkg/util/ingress/ingress.go b/pkg/util/ingress/ingress.go index acadad432..91243e2cc 100644 --- a/pkg/util/ingress/ingress.go +++ b/pkg/util/ingress/ingress.go @@ -282,9 +282,11 @@ func checkPath(paths []networkingv1.HTTPIngressPath, enablePathTypeValidation bo switch pathType := *path.PathType; pathType { case networkingv1.PathTypeImplementationSpecific: - //only match on regex chars per Ingress spec when path is implementation specific - if !regexSpecificChars.MatchString(path.Path) { - return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType) + if enablePathTypeValidation { + //only match on regex chars per Ingress spec when path is implementation specific + if !regexSpecificChars.MatchString(path.Path) { + return fmt.Errorf("path %s of type %s contains invalid characters", path.Path, *path.PathType) + } } case networkingv1.PathTypeExact, networkingv1.PathTypePrefix: diff --git a/pkg/util/ingress/ingress_test.go b/pkg/util/ingress/ingress_test.go index 3bd7f1230..12c2ff1da 100644 --- a/pkg/util/ingress/ingress_test.go +++ b/pkg/util/ingress/ingress_test.go @@ -272,7 +272,7 @@ func TestValidateIngressPath(t *testing.T) { name: "should reject path when the allowed additional set does not match", wantErr: true, additionalChars: "().?", - EnablePathTypeValidation: false, + EnablePathTypeValidation: true, copyIng: generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.+)"), }, { @@ -291,7 +291,7 @@ func TestValidateIngressPath(t *testing.T) { { name: "should block if at least one path is bad", wantErr: true, - EnablePathTypeValidation: false, + EnablePathTypeValidation: true, copyIng: generateComplexIngress(generateDumbIngressforPathTest(&pathTypeImplSpecific, "/foo/bar/(.?)")), }, }