Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddBroker: Escape % in Addresses #319

Merged
merged 1 commit into from Jul 17, 2019
Merged

AddBroker: Escape % in Addresses #319

merged 1 commit into from Jul 17, 2019

Conversation

Mattemagikern
Copy link

The url.Parse(server) will fail if given an address containing a
non escaped % which is the case for an IPv6 address with a zone
indication.

Ex.
[fe80::a604:5838:8d8a:e532%wlp58s0]:1883 => [fe80::a604:5838:8d8a:e532%25wlp58s0]:1883

Regexp explanation:
%(25)?
% -- Match % literally (case sensitive)
(25)? -- Match 25 literally between zero and one time.

=> Will match any % followed by 25 or not.
The Regexp.ReplaceAll(...) will replace all matches of the regular
expression above and replace them with %25. Which is the URL escape code
for %.

Signed-off-by: Måns Ansgariusson mansgariusson@gmail.com

The url.Parse(server) will fail if given an address containing a
non escaped % which is the case for an IPv6 address with a zone
indication.

Ex.
[fe80::a604:5838:8d8a:e532%wlp58s0]:1883 => [fe80::a604:5838:8d8a:e532%25wlp58s0]:1883

Regexp explanation:
`%(25)?`
% - Match % literally (case sensitive)
(25)? -  Match 25 literally between zero and one time.

=> Will match any % followed by 25 or not.
The Regexp.ReplaceAll(...) will replace all matches of the regular
expression above and replace them with %25. Which is the URL escape code
for %.

Signed-off-by: Måns Ansgariusson <mansgariusson@gmail.com>
@alsm
Copy link
Contributor

alsm commented Jul 17, 2019

Thanks

@MattBrittan
Copy link
Contributor

Thought I should add a note to this commit so relevant parties are notified. I am proposing to undo this change because it is causing issues elsewhere (when using web sockets the URL may contain % and escaping this breaks AWS auth). Given that RFC6874 states that % must be escaped I believe the best approach is to undo this change and leave it up to the caller to provide an address that complies with the standard. See issues #469 and #479 for further info.

MattBrittan added a commit to ChIoT-Tech/paho.mqtt.golang that referenced this pull request Jan 28, 2021
…ing). This change broke connections to AWS (and potentially other websocket providers) due to the use of parameters. Ref issues eclipse#479 and eclipse#469.

Signed-off-by: Matt Brittan <matt@brittan.nz>
MattBrittan added a commit that referenced this pull request Jan 28, 2021
Remove changes introduced in PR #319 (escaping % in server string). This may break some apps using IPV6 and passing in a server string that does not comply with RFC6874 (unescaped % in zone identifier). However the original change breaks more use cases so removing it is the best available option.
@MattBrittan
Copy link
Contributor

This change has now been reversed in @master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants