diff options
author | Michael Mercier <michael.mercier@ryax.tech> | 2021-03-15 09:51:14 +0100 |
---|---|---|
committer | Michael Mercier <michael.mercier@ryax.tech> | 2021-03-15 09:51:14 +0100 |
commit | f7180d50f785ec28963e12e647d269650ad89b31 (patch) | |
tree | fcf7b01cebc1b3cd9eb1c6f7acf95c726e4e32d2 | |
parent | b650c4f28bda658d1f3471882520698ef7fb3af6 (diff) | |
download | gitpython-f7180d50f785ec28963e12e647d269650ad89b31.tar.gz |
Use urllib instead of custom parsing
-rw-r--r-- | git/repo/base.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/git/repo/base.py b/git/repo/base.py index 44e3f859..9cb84054 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -9,6 +9,7 @@ import logging import os import re import warnings +from urllib.parse import urlsplit, urlunsplit from git.cmd import ( Git, @@ -971,10 +972,15 @@ class Repo(object): (stdout, stderr) = proc.communicate() cmdline = getattr(proc, 'args', '') uri = cmdline[-2] - if "://" in uri and "@" in uri: - cred = uri.split("://")[1].split("@")[0].split(":") - if len(cred) == 2: - cmdline[-2] = uri.replace(cred[1], "******") + try: + url = urlsplit(uri) + # Remove password from the URL if present + if url.password: + edited_url = url._replace( + netloc=url.netloc.replace(url.password, "****")) + cmdline[-2] = urlunsplit(edited_url) + except ValueError: + log.debug("Unable to parse the URL %s", url) log.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout) finalize_process(proc, stderr=stderr) |