Repository mirroring fails when the password ends with the '@' symbol

Summary

Repository mirroring fails when the password ends with the '@' symbol

Steps to reproduce

I'm using an on-prem deployment of gitlab-ee.

  1. Create a fork of a project and go to Settings > Repository
  2. Expand the 'Pull from a remote repository' section
  3. Check the 'Mirror repository' checkbox and enter the Git repository URL in the form of https://...
  4. In my case, the Authentication method is password, and the password is populated automatically by the gitlab instance. It's important to mention that my password ends with the '@' symbol.
  5. Save settings and wait for a sync

What is the current bug behavior?

Synchronization displays the following message:

Mirror update for some-username/some-repo failed with the following message: fatal: unable to access ':******@@gitlab.mycompany.com/some-group/some-other-repo.git/': Couldn't resolve host '@gitlab.mycompany.com'

It seems that gitlab doesn't escape the password and/or tries to resolve the wrong host afterwards, because it takes the first appearance of the @ symbol (should be the last?)

What is the expected correct behavior?

Gitlab should escape special symbols in the password or should do a proper parse of the URL.

Results of GitLab environment info

Gitlab version is: "version": "9.5.2-ee", "revision": "65f8414c"

Assignee Loading
Time tracking Loading