File tree Expand file tree Collapse file tree 3 files changed +39
-2
lines changed
x/mongo/driver/connstring Expand file tree Collapse file tree 3 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 240
240
"authmechanism" : " MONGODB-CR"
241
241
}
242
242
},
243
+ {
244
+ "description" : " Subdelimiters in user/pass don't need escaping (MONGODB-CR)" ,
245
+ "uri" :
" mongodb://!$&'()*+,;=:!$&'()*+,;[email protected] /admin?authMechanism=MONGODB-CR" ,
246
+ "valid" : true ,
247
+ "warning" : false ,
248
+ "hosts" : [
249
+ {
250
+ "type" : " ipv4" ,
251
+ "host" : " 127.0.0.1" ,
252
+ "port" : null
253
+ }
254
+ ],
255
+ "auth" : {
256
+ "username" : " !$&'()*+,;=" ,
257
+ "password" : " !$&'()*+,;=" ,
258
+ "db" : " admin"
259
+ },
260
+ "options" : {
261
+ "authmechanism" : " MONGODB-CR"
262
+ }
263
+ },
243
264
{
244
265
"description" : " Escaped username (MONGODB-X509)" ,
245
266
"uri" : " mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509" ,
Original file line number Diff line number Diff line change @@ -188,6 +188,22 @@ tests:
188
188
db : " admin?"
189
189
options :
190
190
authmechanism : " MONGODB-CR"
191
+ -
192
+ description : " Subdelimiters in user/pass don't need escaping (MONGODB-CR)"
193
+ uri :
" mongodb://!$&'()*+,;=:!$&'()*+,;[email protected] /admin?authMechanism=MONGODB-CR"
194
+ valid : true
195
+ warning : false
196
+ hosts :
197
+ -
198
+ type : " ipv4"
199
+ host : " 127.0.0.1"
200
+ port : ~
201
+ auth :
202
+ username : " !$&'()*+,;="
203
+ password : " !$&'()*+,;="
204
+ db : " admin"
205
+ options :
206
+ authmechanism : " MONGODB-CR"
191
207
-
192
208
description : " Escaped username (MONGODB-X509)"
193
209
uri : " mongodb://CN%3DmyName%2COU%3DmyOrgUnit%2CO%3DmyOrg%2CL%3DmyLocality%2CST%3DmyState%2CC%3DmyCountry@localhost/?authMechanism=MONGODB-X509"
Original file line number Diff line number Diff line change @@ -233,7 +233,7 @@ func (p *parser) parse(original string) error {
233
233
if strings .Contains (username , "/" ) {
234
234
return fmt .Errorf ("unescaped slash in username" )
235
235
}
236
- p .Username , err = url .QueryUnescape (username )
236
+ p .Username , err = url .PathUnescape (username )
237
237
if err != nil {
238
238
return internal .WrapErrorf (err , "invalid username" )
239
239
}
@@ -246,7 +246,7 @@ func (p *parser) parse(original string) error {
246
246
if strings .Contains (password , "/" ) {
247
247
return fmt .Errorf ("unescaped slash in password" )
248
248
}
249
- p .Password , err = url .QueryUnescape (password )
249
+ p .Password , err = url .PathUnescape (password )
250
250
if err != nil {
251
251
return internal .WrapErrorf (err , "invalid password" )
252
252
}
You can’t perform that action at this time.
0 commit comments