Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2017-09-06 17:20:25 +0300
committerNick Thomas <nick@gitlab.com>2017-09-06 17:29:14 +0300
commitc8bdb20228b34130c7f0525ad92140702dce1e20 (patch)
tree1783f5e8df0534f7df2b8ab371d1359d0cdc38f3 /lib/gitlab/url_sanitizer.rb
parent759f34bd0a250cb2cdf1b718837b56bb28fa1939 (diff)
Remove blank passwords from sanitized URLs
Diffstat (limited to 'lib/gitlab/url_sanitizer.rb')
-rw-r--r--lib/gitlab/url_sanitizer.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb
index 9c26490f40f..703adae12cb 100644
--- a/lib/gitlab/url_sanitizer.rb
+++ b/lib/gitlab/url_sanitizer.rb
@@ -19,7 +19,12 @@ module Gitlab
end
def initialize(url, credentials: nil)
- @url = Addressable::URI.parse(url.strip)
+ @url = Addressable::URI.parse(url.to_s.strip)
+
+ %i[user password].each do |symbol|
+ credentials[symbol] = credentials[symbol].presence if credentials&.key?(symbol)
+ end
+
@credentials = credentials
end
@@ -47,8 +52,10 @@ module Gitlab
def generate_full_url
return @url unless valid_credentials?
@full_url = @url.dup
- @full_url.user = credentials[:user].presence
- @full_url.password = credentials[:password].presence
+
+ @full_url.password = credentials[:password]
+ @full_url.user = credentials[:user]
+
@full_url
end