Merge branch 'sh-handle-colons-in-url-passwords' into 'master'
Properly handle colons in URL passwords Closes #49080 See merge request gitlab-org/gitlab-ce!20538
This commit is contained in:
commit
c6b670216c
3 changed files with 7 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Properly handle colons in URL passwords
|
||||
merge_request:
|
||||
author:
|
||||
type: fixed
|
|
@ -58,7 +58,7 @@ module Gitlab
|
|||
if raw_credentials.present?
|
||||
url.sub!("#{raw_credentials}@", '')
|
||||
|
||||
user, password = raw_credentials.split(':')
|
||||
user, _, password = raw_credentials.partition(':')
|
||||
@credentials ||= { user: user.presence, password: password.presence }
|
||||
end
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ describe Gitlab::UrlSanitizer do
|
|||
context 'credentials in URL' do
|
||||
where(:url, :credentials) do
|
||||
'http://foo:bar@example.com' | { user: 'foo', password: 'bar' }
|
||||
'http://foo:bar:baz@example.com' | { user: 'foo', password: 'bar:baz' }
|
||||
'http://:bar@example.com' | { user: nil, password: 'bar' }
|
||||
'http://foo:@example.com' | { user: 'foo', password: nil }
|
||||
'http://foo@example.com' | { user: 'foo', password: nil }
|
||||
|
|
Loading…
Reference in a new issue