Skip to content

Commit 62acaa1

Browse files
committed
Encode id and key in url to clone git
Signed-off-by: 석지영/책임연구원/SW공학(연)Open Source TP <[email protected]>
1 parent 5858dae commit 62acaa1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/fosslight_util/download.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import subprocess
2727
import re
2828
from typing import Tuple
29+
import urllib.parse
2930

3031
logger = logging.getLogger(constant.LOGGER_NAME)
3132
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
256257
m = re.match(r"^(ht|f)tp(s?)\:\/\/", git_url)
257258
protocol = m.group()
258259
if protocol:
259-
git_url = git_url.replace(protocol, f"{protocol}{id}:{git_token}@")
260+
encoded_git_token = urllib.parse.quote(git_token, safe='')
261+
encoded_id = urllib.parse.quote(id, safe='')
262+
git_url = git_url.replace(protocol, f"{protocol}{encoded_id}:{encoded_git_token}@")
260263
except Exception as error:
261264
logger.info(f"Failed to insert id, token to git url:{error}")
262265
success, oss_version = download_git_repository(refs_to_checkout, git_url, target_dir, tag)

0 commit comments

Comments
 (0)