casbin / mongodb-adapter

MongoDB adapter for Casbin

Home Page:https://github.com/casbin/casbin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bug of NewAdapter's neturl.Parse(url) which username or password contains special characters such as ": / ? # [ ] @"

SoaringTiger opened this issue · comments

MongoDB's username or password can contain special characters such as ": / ? # [ ] @",

When parsing one legal mongo url like this:

mongodb://admin:pass#_2022@127.0.0.1/test_users

neturl.Parse(url) will fail:

       u, err := neturl.Parse(url)
	if err != nil {
		return nil, err
	}

the error is:

parse "mongodb://admin:pass": invalid port ":pass" after host

There is an official package "go.mongodb.org/mongo-driver/x/mongo/driver/connstring" will solve it.