Skip to content

Commit

Permalink
GODRIVER-3050 Ignore the case for the UNIX socket filename. (#1460)
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyang-hu authored Dec 11, 2023
1 parent 7211924 commit 6ddf780
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mongo/address/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@ func (a Address) Network() string {
// String is the canonical version of this address, e.g. localhost:27017,
// 1.2.3.4:27017, example.com:27017.
func (a Address) String() string {
// TODO: unicode case folding?
s := strings.ToLower(string(a))
s := string(a)
if a.Network() != "unix" {
// TODO: unicode case folding?
s = strings.ToLower(string(a))
}
if len(s) == 0 {
return ""
}
Expand Down
1 change: 1 addition & 0 deletions mongo/address/addr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestAddress_String(t *testing.T) {
{"A:27017", "a:27017"},
{"a:27017", "a:27017"},
{"a.sock", "a.sock"},
{"A.sock", "A.sock"},
}

for _, test := range tests {
Expand Down
15 changes: 15 additions & 0 deletions testdata/connection-string/valid-unix_socket-absolute.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@
"auth": null,
"options": null
},
{
"description": "Unix domain socket (mixed case)",
"uri": "mongodb://%2Ftmp%2FMongoDB-27017.sock",
"valid": true,
"warning": false,
"hosts": [
{
"type": "unix",
"host": "/tmp/MongoDB-27017.sock",
"port": null
}
],
"auth": null,
"options": null
},
{
"description": "Unix domain socket (absolute path with spaces in path)",
"uri": "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock",
Expand Down
12 changes: 12 additions & 0 deletions testdata/connection-string/valid-unix_socket-absolute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ tests:
port: ~
auth: ~
options: ~
-
description: "Unix domain socket (mixed case)"
uri: "mongodb://%2Ftmp%2FMongoDB-27017.sock"
valid: true
warning: false
hosts:
-
type: "unix"
host: "/tmp/MongoDB-27017.sock"
port: ~
auth: ~
options: ~
-
description: "Unix domain socket (absolute path with spaces in path)"
uri: "mongodb://%2Ftmp%2F %2Fmongodb-27017.sock"
Expand Down
15 changes: 15 additions & 0 deletions testdata/connection-string/valid-unix_socket-relative.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@
"auth": null,
"options": null
},
{
"description": "Unix domain socket (mixed case)",
"uri": "mongodb://rel%2FMongoDB-27017.sock",
"valid": true,
"warning": false,
"hosts": [
{
"type": "unix",
"host": "rel/MongoDB-27017.sock",
"port": null
}
],
"auth": null,
"options": null
},
{
"description": "Unix domain socket (relative path with spaces)",
"uri": "mongodb://rel%2F %2Fmongodb-27017.sock",
Expand Down
12 changes: 12 additions & 0 deletions testdata/connection-string/valid-unix_socket-relative.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ tests:
port: ~
auth: ~
options: ~
-
description: "Unix domain socket (mixed case)"
uri: "mongodb://rel%2FMongoDB-27017.sock"
valid: true
warning: false
hosts:
-
type: "unix"
host: "rel/MongoDB-27017.sock"
port: ~
auth: ~
options: ~
-
description: "Unix domain socket (relative path with spaces)"
uri: "mongodb://rel%2F %2Fmongodb-27017.sock"
Expand Down

0 comments on commit 6ddf780

Please sign in to comment.