diff --git a/settings.go b/settings.go index ba0743f82..97c9353e0 100644 --- a/settings.go +++ b/settings.go @@ -3,9 +3,10 @@ package quickfix import ( "bufio" "fmt" - "github.com/quickfixgo/quickfix/config" "io" "regexp" + + "github.com/quickfixgo/quickfix/config" ) //The Settings type represents a collection of global and session settings. @@ -67,7 +68,7 @@ func ParseSettings(reader io.Reader) (*Settings, error) { commentRegEx := regexp.MustCompile(`^#.*`) defaultRegEx := regexp.MustCompile(`^\[(?i)DEFAULT\]\s*$`) sessionRegEx := regexp.MustCompile(`^\[(?i)SESSION\]\s*$`) - settingRegEx := regexp.MustCompile(`^(.*)=(.*)$`) + settingRegEx := regexp.MustCompile(`^([^=]*)=(.*)$`) var settings *SessionSettings diff --git a/settings_test.go b/settings_test.go index 97731b66c..67f6d60b8 100644 --- a/settings_test.go +++ b/settings_test.go @@ -1,9 +1,12 @@ package quickfix import ( - "github.com/quickfixgo/quickfix/config" "strings" "testing" + + "github.com/quickfixgo/quickfix/config" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestSettings_New(t *testing.T) { @@ -266,6 +269,27 @@ DataDictionary=somewhere/FIX42.xml } } +func TestSettings_ParseSettings_WithEqualsSignInValue(t *testing.T) { + s, err := ParseSettings(strings.NewReader(` +[DEFAULT] +ConnectionType=initiator +SQLDriver=mysql +SQLDataSourceName=root:root@/quickfix?parseTime=true&loc=UTC + +[SESSION] +BeginString=FIX.4.2 +SenderCompID=SENDER +TargetCompID=TARGET`)) + + require.Nil(t, err) + require.NotNil(t, s) + + sessionSettings := s.SessionSettings()[SessionID{BeginString: "FIX.4.2", SenderCompID: "SENDER", TargetCompID: "TARGET"}] + val, err := sessionSettings.Setting("SQLDataSourceName") + assert.Nil(t, err) + assert.Equal(t, `root:root@/quickfix?parseTime=true&loc=UTC`, val) +} + func TestSettings_SessionIDFromSessionSettings(t *testing.T) { var testCases = []struct { globalBeginString string