You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/02/01 16:04:39 UTC
[camel-k] branch master updated: Fix CSV map string parsing
This is an automated email from the ASF dual-hosted git repository.
lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new e4fb63b Fix CSV map string parsing
e4fb63b is described below
commit e4fb63bf24b646d81fc34b0c5eb098e1a343ed77
Author: Antonin Stefanutti <an...@stefanutti.fr>
AuthorDate: Fri Feb 1 15:47:16 2019 +0100
Fix CSV map string parsing
---
pkg/trait/util.go | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/pkg/trait/util.go b/pkg/trait/util.go
index 3d58f74..b0dbff7 100644
--- a/pkg/trait/util.go
+++ b/pkg/trait/util.go
@@ -103,7 +103,8 @@ func VisitKeyValConfigurations(
}
var (
- csvMapRegexp = regexp.MustCompile(`^(\w+)=([^,]+)(?:,(\w+)=([^,]+))*$`)
+ csvMapValidatingRegexp = regexp.MustCompile(`^(\w+)=([^,]+)(?:,(\w+)=([^,]+))*$`)
+ csvMapParsingRegexp = regexp.MustCompile(`(\w+)=([^,]+)`)
)
func parseCsvMap(csvMap *string) (map[string]string, error) {
@@ -113,13 +114,13 @@ func parseCsvMap(csvMap *string) (map[string]string, error) {
return m, nil
}
- if !csvMapRegexp.MatchString(*csvMap) {
+ if !csvMapValidatingRegexp.MatchString(*csvMap) {
return nil, fmt.Errorf("cannot parse [%s] as CSV map", *csvMap)
}
- matches := csvMapRegexp.FindStringSubmatch(*csvMap)[2:]
- for i := range matches[:len(matches)-1] {
- m[matches[i]] = matches[i+1]
+ matches := csvMapParsingRegexp.FindAllStringSubmatch(*csvMap, -1)
+ for i := range matches {
+ m[matches[i][1]] = matches[i][2]
}
return m, nil