Skip to content

Commit

Permalink
Merge pull request #480 from ChIoT-Tech/master
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MattBrittan committed Jan 28, 2021
2 parents deddaa7 + 74716b9 commit eb1be68
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions options.go
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/tls"
"net/http"
"net/url"
"regexp"
"strings"
"time"
)
Expand Down Expand Up @@ -137,14 +136,12 @@ func NewClientOptions() *ClientOptions {
//
// An example broker URI would look like: tcp://foobar.com:1883
func (o *ClientOptions) AddBroker(server string) *ClientOptions {
re := regexp.MustCompile(`%(25)?`)
if len(server) > 0 && server[0] == ':' {
server = "127.0.0.1" + server
}
if !strings.Contains(server, "://") {
server = "tcp://" + server
}
server = re.ReplaceAllLiteralString(server, "%25")
brokerURI, err := url.Parse(server)
if err != nil {
ERROR.Println(CLI, "Failed to parse %q broker address: %s", server, err)
Expand Down

0 comments on commit eb1be68

Please sign in to comment.