njh / ruby-mqtt

Pure Ruby gem that implements the MQTT protocol, a lightweight protocol for publish/subscribe messaging.
http://www.rubydoc.info/gems/mqtt
MIT License
541 stars 135 forks source link

Encoded URI username and password #93

Closed marclennox closed 7 years ago

marclennox commented 7 years ago

I'm trying to use the URI connection format with username and password in the URI, however if the username or password contain special characters, my understanding is that you are supposed to CGI escape them (percent escape).

It seems though that this library does not decode the username and password, so authentication fails.

Would you accept a PR that de-escapes them?

njh commented 7 years ago

Certainly - please add some tests too.

URIs aren't part of any official specification at the moment, but there is this Wiki page: https://github.com/mqtt/mqtt.github.io/wiki/URI-Scheme

It might be worth updating/clarifying in that.

njh commented 7 years ago

I have fixed username/password unescaping in 333087777c015837311d71c4144fa716c028f551.

I am a bit confused why ruby doesn't do this in URI.parse.

But there is a test to verify that this doesn't change/break.

marclennox commented 7 years ago

Hey @njh, thanks for this! This was on my list to get done, just hadn't got around to it yet. I totally agree though, this seems like something that URI.parse should handle.