summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Mercier <michael.mercier@ryax.tech>2021-03-15 09:51:14 +0100
committerMichael Mercier <michael.mercier@ryax.tech>2021-03-15 09:51:14 +0100
commitf7180d50f785ec28963e12e647d269650ad89b31 (patch)
treefcf7b01cebc1b3cd9eb1c6f7acf95c726e4e32d2
parentb650c4f28bda658d1f3471882520698ef7fb3af6 (diff)
downloadgitpython-f7180d50f785ec28963e12e647d269650ad89b31.tar.gz
Use urllib instead of custom parsing
-rw-r--r--git/repo/base.py14
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)