Commit 6331bc87 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'issue_support_667' into 'master'

Parse Repository URLs with Addressable instead of URI

Addressable is more modern than URI and supports scp-like URLs which are
common when referencing Git repositories.

REF: https://gitlab.com/gitlab-com/support-forum/issues/667
Sentry: https://sentry.gitlap.com/gitlab/gitlabcom/issues/4324

See merge request !397
parents b289cc08 75e06061
...@@ -7,7 +7,7 @@ module Gitlab ...@@ -7,7 +7,7 @@ module Gitlab
end end
def initialize(url, credentials: nil) def initialize(url, credentials: nil)
@url = URI.parse(URI.encode(url)) @url = Addressable::URI.parse(URI.encode(url))
@credentials = credentials @credentials = credentials
end end
......
...@@ -8,6 +8,12 @@ describe Gitlab::UrlSanitizer, lib: true do ...@@ -8,6 +8,12 @@ describe Gitlab::UrlSanitizer, lib: true do
describe '#full_url' do describe '#full_url' do
it { expect(url_sanitizer.full_url).to eq("https://blah:password@github.com/me/project.git") } it { expect(url_sanitizer.full_url).to eq("https://blah:password@github.com/me/project.git") }
it 'supports scp-like URLs' do
sanitizer = described_class.new('user@server:project.git')
expect(sanitizer.full_url).to eq('user@server:project.git')
end
end end
describe '#sanitized_url' do describe '#sanitized_url' do
...@@ -28,6 +34,8 @@ describe Gitlab::UrlSanitizer, lib: true do ...@@ -28,6 +34,8 @@ describe Gitlab::UrlSanitizer, lib: true do
ssh://user@host.test/path/to/repo.git ssh://user@host.test/path/to/repo.git
remote: Not Found remote: Not Found
git://host.test/path/to/repo.git git://host.test/path/to/repo.git
remote: Not Found
user@server:project.git
}) })
end end
...@@ -47,5 +55,9 @@ describe Gitlab::UrlSanitizer, lib: true do ...@@ -47,5 +55,9 @@ describe Gitlab::UrlSanitizer, lib: true do
# git protocol does not support authentication # git protocol does not support authentication
expect(filtered_content).to include("git://host.test/path/to/repo.git") expect(filtered_content).to include("git://host.test/path/to/repo.git")
end end
it 'does not modify scp-like URLs' do
expect(filtered_content).to include("user@server:project.git")
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment