From 62acaa1d8847c4d77ea1d6dcfafb7f03da14fd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=9D=EC=A7=80=EC=98=81/=EC=B1=85=EC=9E=84=EC=97=B0?= =?UTF-8?q?=EA=B5=AC=EC=9B=90/SW=EA=B3=B5=ED=95=99=28=EC=97=B0=29Open=20So?= =?UTF-8?q?urce=20TP?= Date: Wed, 18 Jun 2025 15:33:44 +0900 Subject: [PATCH] Encode id and key in url to clone git MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 석지영/책임연구원/SW공학(연)Open Source TP --- src/fosslight_util/download.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/fosslight_util/download.py b/src/fosslight_util/download.py index 228b20c..615bd9e 100755 --- a/src/fosslight_util/download.py +++ b/src/fosslight_util/download.py @@ -26,6 +26,7 @@ import subprocess import re from typing import Tuple +import urllib.parse logger = logging.getLogger(constant.LOGGER_NAME) compression_extension = {".tar.bz2", ".tar.gz", ".tar.xz", ".tgz", ".tar", ".zip", ".jar", ".bz2"} @@ -256,7 +257,9 @@ def download_git_clone(git_url, target_dir, checkout_to="", tag="", branch="", s m = re.match(r"^(ht|f)tp(s?)\:\/\/", git_url) protocol = m.group() if protocol: - git_url = git_url.replace(protocol, f"{protocol}{id}:{git_token}@") + encoded_git_token = urllib.parse.quote(git_token, safe='') + encoded_id = urllib.parse.quote(id, safe='') + git_url = git_url.replace(protocol, f"{protocol}{encoded_id}:{encoded_git_token}@") except Exception as error: logger.info(f"Failed to insert id, token to git url:{error}") success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)