mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-05 15:37:19 +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:
parent
496c3059d0
commit
139551b7ac
2 changed files with 5 additions and 3 deletions
|
@ -11,7 +11,7 @@ var (
|
|||
RegexReferences = regexp.MustCompile(`^\$\(.[^\ ]*\)|[^\\]\$\(.[^\ ]*\)`)
|
||||
|
||||
// RegexEscpReferences is the Regex for '\$(...)'
|
||||
RegexEscpReferences = regexp.MustCompile(`\\\$\(.[^\ ]*\)`)
|
||||
RegexEscpReferences = regexp.MustCompile(`\\\$\(.[^\ \)]*\)`)
|
||||
|
||||
RegexVariableInit = regexp.MustCompile(`^\{\{(\{[^{}]*\}|[^{}])*\}\}`)
|
||||
|
||||
|
|
|
@ -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)": {
|
||||
|
|
Loading…
Add table
Reference in a new issue