diff --git a/pkg/util/attributes/parser.go b/pkg/util/attributes/parser.go index 340443bff..46562a4ca 100644 --- a/pkg/util/attributes/parser.go +++ b/pkg/util/attributes/parser.go @@ -59,16 +59,16 @@ func ParseV2Attributes(attrs []string, excl []string) ([]*netmap.NodeAttribute, } if !present { + attribute = netmap.NewNodeAttribute() + cache[key] = attribute + result = append(result, attribute) + // replace non-printable symbols with escaped symbols without escape character key = replaceEscaping(key, true) value = replaceEscaping(value, true) - attribute = netmap.NewNodeAttribute() attribute.SetKey(key) attribute.SetValue(value) - - cache[key] = attribute - result = append(result, attribute) } if parentKey != "" { diff --git a/pkg/util/attributes/parser_test.go b/pkg/util/attributes/parser_test.go index c9c0c9978..87fcef2a0 100644 --- a/pkg/util/attributes/parser_test.go +++ b/pkg/util/attributes/parser_test.go @@ -74,6 +74,13 @@ func TestParseV2Attributes(t *testing.T) { attrs, err := attributes.ParseV2Attributes(from, nil) require.NoError(t, err) require.Len(t, attrs, 1) + + t.Run("with escape characters", func(t *testing.T) { + from = []string{`/a\::b\/`, `/a\::b\/`} + attrs, err := attributes.ParseV2Attributes(from, nil) + require.NoError(t, err) + require.Len(t, attrs, 1) + }) }) t.Run("multiple parents", func(t *testing.T) {