Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plubming: transport, Escape the user and pswd for endpoint. Fixes #723 #762

Merged
merged 1 commit into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plumbing/transport/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ func (u *Endpoint) String() string {
buf.WriteString("//")

if u.User != "" || u.Password != "" {
buf.WriteString(u.User)
buf.WriteString(url.PathEscape(u.User))
if u.Password != "" {
buf.WriteByte(':')
buf.WriteString(u.Password)
buf.WriteString(url.PathEscape(u.Password))
}

buf.WriteByte('@')
Expand Down
10 changes: 10 additions & 0 deletions plumbing/transport/common_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package transport

import (
"net/url"
"testing"

"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp/capability"
Expand Down Expand Up @@ -153,6 +154,15 @@ func (s *SuiteCommon) TestNewEndpointFileURL(c *C) {
c.Assert(e.String(), Equals, "file:///foo.git")
}

func (s *SuiteCommon) TestValidEndpoint(c *C) {
e, err := NewEndpoint("http://github.com/user/repository.git")
e.User = "[email protected]"
e.Password = " !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
url, err := url.Parse(e.String())
c.Assert(err, IsNil)
c.Assert(url, NotNil)
}

func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {
e, err := NewEndpoint("http://\\")
c.Assert(err, NotNil)
Expand Down