[GODRIVER-2644] The Percent Encoded Password Connectstring is not parsed correctly in the topology at Connect time Created: 07/Nov/22  Updated: 27/Oct/23  Resolved: 07/Nov/22

Status: Closed
Project: Go Driver
Component/s: Connection String, Connections
Affects Version/s: 1.11.0, 1.10.4
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: Marco Rozzati Assignee: Unassigned
Resolution: Works as Designed Votes: 0
Labels: Bug
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Summary

In topology.go (v1.11.0) line 239 connection string t.cfg.URI is parsed with generic url.Parse(...) instead of connstring.Parse(...)

If connection string contains Percent Encoded Password reports error (as example)

parse "mongodb+srv://user:test%2F%40": invalid port ":test%2F%40" after host

in func (t *Topology) Connect() error {...} 

How to Reproduce

Is possible to reproduce using mongo Client Connect with a connection string with these characteristics

func TestURI(t *testing.T)

{   uri0 := "mongodb+srv://user:test%2F%40pwd@myatlasproject.mongodb.net/admin?retryWrites=true&w=majority"   uri, err := url.Parse(uri0)   // uri, err := connstring.Parse(uri0)   assert.NoError(t, err)   fmt.Println(uri) }

Additional Background

I suggest replacing the command in topology.go [line 239 in function Connect()]

uri, err := url.Parse(t.cfg.URI)

with 

uri, err := connstring.Parse(t.cfg.URI)

 

NOTE:

I have set the bug as a blocker because it does not allow me to keep the library up to date, but I don't know if it matches your priority criteria



 Comments   
Comment by Marco Rozzati [ 07/Nov/22 ]

I'm SORRY, please reject the bug
=========================

This connection-string reports exactly the error

mongodb+srv://user:<C%2F%40#@myatlasproject.mongodb.net/admin?retryWrites=true&w=majority

Received unexpected error:
parse "mongodb+srv://user:<C%2F%40": invalid port ":<C%2F%40" after host

BUT this connection string is not correctly escaped, although it worked flawlessly in older versions!

I Apologize!

Generated at Thu Feb 08 08:39:04 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.