Commit c6b67021 authored by James Lopez's avatar James Lopez

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
parents c2a0a3ab 718a23fd
---
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 }
......
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