Skip to content

Commit 2a62c04

Browse files
committed
Allow settings values to contain equals signs
Adjusted the regexp to allow equals signs in values. Allows parsing of settings like: `SQLDataSourceName=/quickfix?parseTime=true&loc=UTC`.
1 parent bbfb717 commit 2a62c04

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

settings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ package quickfix
33
import (
44
"bufio"
55
"fmt"
6-
"github.com/quickfixgo/quickfix/config"
76
"io"
87
"regexp"
8+
9+
"github.com/quickfixgo/quickfix/config"
910
)
1011

1112
//The Settings type represents a collection of global and session settings.
@@ -67,7 +68,7 @@ func ParseSettings(reader io.Reader) (*Settings, error) {
6768
commentRegEx := regexp.MustCompile(`^#.*`)
6869
defaultRegEx := regexp.MustCompile(`^\[(?i)DEFAULT\]\s*$`)
6970
sessionRegEx := regexp.MustCompile(`^\[(?i)SESSION\]\s*$`)
70-
settingRegEx := regexp.MustCompile(`^(.*)=(.*)$`)
71+
settingRegEx := regexp.MustCompile(`^([^=]*)=(.*)$`)
7172

7273
var settings *SessionSettings
7374

settings_test.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package quickfix
22

33
import (
4-
"github.com/quickfixgo/quickfix/config"
54
"strings"
65
"testing"
6+
7+
"github.com/quickfixgo/quickfix/config"
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
710
)
811

912
func TestSettings_New(t *testing.T) {
@@ -266,6 +269,27 @@ DataDictionary=somewhere/FIX42.xml
266269
}
267270
}
268271

272+
func TestSettings_ParseSettings_WithEqualsSignInValue(t *testing.T) {
273+
s, err := ParseSettings(strings.NewReader(`
274+
[DEFAULT]
275+
ConnectionType=initiator
276+
SQLDriver=mysql
277+
SQLDataSourceName=root:root@/quickfix?parseTime=true&loc=UTC
278+
279+
[SESSION]
280+
BeginString=FIX.4.2
281+
SenderCompID=SENDER
282+
TargetCompID=TARGET`))
283+
284+
require.Nil(t, err)
285+
require.NotNil(t, s)
286+
287+
sessionSettings := s.SessionSettings()[SessionID{BeginString: "FIX.4.2", SenderCompID: "SENDER", TargetCompID: "TARGET"}]
288+
val, err := sessionSettings.Setting("SQLDataSourceName")
289+
assert.Nil(t, err)
290+
assert.Equal(t, `root:root@/quickfix?parseTime=true&loc=UTC`, val)
291+
}
292+
269293
func TestSettings_SessionIDFromSessionSettings(t *testing.T) {
270294
var testCases = []struct {
271295
globalBeginString string

0 commit comments

Comments
 (0)