diff --git a/backend/plugin/installer.py b/backend/plugin/installer.py index 326416b0..01f58dbc 100644 --- a/backend/plugin/installer.py +++ b/backend/plugin/installer.py @@ -118,7 +118,7 @@ async def install_git_plugin(repo_url: str) -> str: """ match = is_git_url(repo_url) if not match: - raise errors.RequestError(msg='Git 仓库地址格式非法') + raise errors.RequestError(msg='Git 仓库地址格式非法,仅支持 HTTP/HTTPS 协议') repo_name = match.group('repo') path = anyio.Path(PLUGIN_DIR / repo_name) if await path.exists(): diff --git a/backend/utils/pattern_validate.py b/backend/utils/pattern_validate.py index 3d6cf274..06e90250 100644 --- a/backend/utils/pattern_validate.py +++ b/backend/utils/pattern_validate.py @@ -36,12 +36,12 @@ def is_phone(number: str) -> re.Match[str]: def is_git_url(url: str) -> re.Match[str]: """ - 检查 git URL 格式 + 检查 git URL 格式(仅允许 HTTP/HTTPS 协议) :param url: 待检查的 URL :return: """ - git_pattern = r'^(?!(git\+ssh|ssh)://|git@)(?Pgit|https?|file)://(?P[^/]*)(?P(?:/[^/]*)*/)(?P[^/]+?)(?:\.git)?$' + git_pattern = r'^(?Phttps?)://(?P[^/]*)(?P(?:/[^/]*)*/)(?P[^/]+?)(?:\.git)?$' return match_string(git_pattern, url)