Skip to content

Commit

Permalink
🐛 Escape parentheses before where substitution (#109)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabian von Feilitzsch <fabian@fabianism.us>
  • Loading branch information
fabianvf committed Jan 5, 2024
1 parent 341e021 commit 48434a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/conversion/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func convertWindupWhenToAnalyzer(windupWhen windup.When, where map[string]string
//}
condition := map[string]interface{}{
"builtin.filecontent": map[string]interface{}{
"pattern": convertWindupRegex(substituteWhere(where, fc.Pattern)),
"pattern": convertWindupRegex(substituteWhere(where, escapeParens(fc.Pattern))),
"filePattern": escapeDots(convertWindupRegex(substituteWhere(where, fc.Filename))),
},
}
Expand Down Expand Up @@ -976,3 +976,9 @@ func convertWindupRegex(regex string) string {
}
return regex
}

func escapeParens(s string) string {
s = strings.Replace(s, "(", "\\(", -1)
s = strings.Replace(s, ")", "\\)", -1)
return s
}

0 comments on commit 48434a4

Please sign in to comment.