Commit e27dc776 authored by Nick Thomas's avatar Nick Thomas

Fix problems with Gitlab::UrlSanitizer

parent 6e31e1b8
......@@ -49,20 +49,20 @@ module Gitlab
private
def parse_url(url)
url = url.strip
match = url.match(%r{\A(?:ssh|http(?:s?))\://(?:(.+)(?:@))?(.+)})
url = url.to_s.strip
match = url.match(%r{\A(?:git|ssh|http(?:s?))\://(?:(.+)(?:@))?(.+)})
raw_credentials = match[1] if match
if raw_credentials.present?
url.sub!("#{raw_credentials}@", '')
user, password = raw_credentials.split(':')
@credentials ||= { user: user, password: password }
@credentials ||= { user: user.presence, password: password.presence }
end
url = Addressable::URI.parse(url)
url.user = user
url.password = password
url.password = password if password.present?
url.user = user if user.present?
url
end
......@@ -70,8 +70,8 @@ module Gitlab
return @url unless valid_credentials?
@full_url = @url.dup
@full_url.password = credentials[:password]
@full_url.user = credentials[:user]
@full_url.password = credentials[:password] if credentials[:password].present?
@full_url.user = credentials[:user] if credentials[:user].present?
@full_url
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