From e7735dc16ff443926c42f1cd824781830521fdf7 Mon Sep 17 00:00:00 2001 From: Don Khan Date: Mon, 9 Dec 2024 16:05:14 -0500 Subject: [PATCH] Use escaped ampersand for multiple arrays. --- service/preinit.go | 4 ++-- service/preinit_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/service/preinit.go b/service/preinit.go index c73d7893..7dafdff1 100644 --- a/service/preinit.go +++ b/service/preinit.go @@ -91,7 +91,7 @@ func (s *service) PreInit() error { for _, connectionData := range arrayConfig { if connectionData.Mdm != "" { if sb.Len() > 0 { - sb.WriteString("&") + sb.WriteString("\\&") } sb.WriteString(connectionData.Mdm) } @@ -140,7 +140,7 @@ func getMdmList(connectionData []*ArrayConnectionData, key, zone string) (string for _, connectionData := range connectionData { if connectionData.Mdm != "" && connectionData.Zone.LabelKey == key && connectionData.Zone.Name == zone { if sb.Len() > 0 { - sb.WriteString("&") + sb.WriteString("\\&") } sb.WriteString(connectionData.Mdm) } diff --git a/service/preinit_test.go b/service/preinit_test.go index c7763251..2a32e2fc 100644 --- a/service/preinit_test.go +++ b/service/preinit_test.go @@ -112,7 +112,7 @@ func TestPreInit(t *testing.T) { }, }, errorExpected: false, - expectedResult: "192.168.1.1,192.168.1.2&192.168.2.1,192.168.2.2", + expectedResult: "192.168.1.1,192.168.1.2\\&192.168.2.1,192.168.2.2", }, { name: "should fail if zones configured but unable to fetch node labels", @@ -353,7 +353,7 @@ func TestGetMdmList(t *testing.T) { key: "testKey", zone: "testZone", errorExpected: false, - expectedResult: "192.168.0.10,192.168.0.20&192.168.1.10,192.168.1.20", + expectedResult: "192.168.0.10,192.168.0.20\\&192.168.1.10,192.168.1.20", }, { name: "two arrays with one MDM each", @@ -372,7 +372,7 @@ func TestGetMdmList(t *testing.T) { key: "testKey", zone: "testZone", errorExpected: false, - expectedResult: "192.168.0.10&192.168.1.10", + expectedResult: "192.168.0.10\\&192.168.1.10", }, { name: "two arrays with multiple zones 1",