mongo-uri-builder icon indicating copy to clipboard operation
mongo-uri-builder copied to clipboard

Password contains an illegal unescaped character

Open Yash-Pal-Web opened this issue 4 years ago • 2 comments

Yash-Pal-Web avatar Feb 03 '21 11:02 Yash-Pal-Web

I've reviewed this and confirmed it's a bug. The password should be URI-encoded, but this library does not current encode it, nor document that a pre-encoded value should be provided.

I believe the fix is to add encodeURIComponent(config.password) to the built string instead of just config.password.

But I also recommend this workaround: Generate passwords in the first place that don't use any of the reserved characters used by URI Encoding so that they don't require encoding. This is easy to do with the crypto-random-string module which has a uri-safe option for this purpose.

markstos avatar Aug 20 '21 15:08 markstos

Can be closed as a duplicate of #2.

markstos avatar Aug 20 '21 15:08 markstos