1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-05 07:26:55 +00:00

fix: use ungreedy pattern to process all variables (#8311)

* use ungreedy pattern to process all variables

Signed-off-by: Romuald du Song <rdusong@chapsvision.com>

* use different strategy for regexp to remove the use of ungreedy flag

Signed-off-by: Romuald du Song <rdusong@chapsvision.com>

---------

Signed-off-by: Romuald du Song <rdusong@chapsvision.com>
This commit is contained in:
Romuald 2023-11-14 14:23:28 +01:00 committed by GitHub
parent 496c3059d0
commit 139551b7ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -11,7 +11,7 @@ var (
RegexReferences = regexp.MustCompile(`^\$\(.[^\ ]*\)|[^\\]\$\(.[^\ ]*\)`)
// RegexEscpReferences is the Regex for '\$(...)'
RegexEscpReferences = regexp.MustCompile(`\\\$\(.[^\ ]*\)`)
RegexEscpReferences = regexp.MustCompile(`\\\$\(.[^\ \)]*\)`)
RegexVariableInit = regexp.MustCompile(`^\{\{(\{[^{}]*\}|[^{}])*\}\}`)

View file

@ -1100,7 +1100,8 @@ func Test_EscpReferenceSubstitution(t *testing.T) {
"test1": "$(../../../../spec/namespace)",
"test2": "\\$(ENV_VAR)",
"test3": "\\${ENV_VAR}",
"test4": "\\\\\\${ENV_VAR}"
"test4": "\\\\\\${ENV_VAR}",
"test5": "\\$(NODE_NAME)/postgres/\\$(POD_NAME)"
}
},
"(spec)": {
@ -1118,7 +1119,8 @@ func Test_EscpReferenceSubstitution(t *testing.T) {
"test1": "n1",
"test2": "$(ENV_VAR)",
"test3": "\\${ENV_VAR}",
"test4": "\\\\\\${ENV_VAR}"
"test4": "\\\\\\${ENV_VAR}",
"test5": "$(NODE_NAME)/postgres/$(POD_NAME)"
}
},
"(spec)": {