Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GODRIVER-3050 Ignore the case for the UNIX socket filename. #1460

Merged
merged 3 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading