diff --git a/actions/__init__.py b/actions/__init__.py index fefdbcb..a3c0bfb 100644 --- a/actions/__init__.py +++ b/actions/__init__.py @@ -28,4 +28,4 @@ # ├── test_summarize_pr.py # └── ... -__version__ = "0.3.14" +__version__ = "0.3.15" diff --git a/actions/utils/common_utils.py b/actions/utils/common_utils.py index 4113039..5c574c7 100644 --- a/actions/utils/common_utils.py +++ b/actions/utils/common_utils.py @@ -147,7 +147,6 @@ REDIRECT_START_IGNORE_LIST = frozenset( "ultralytics.com/assets", "app.gong.io/call?", "docs.openvino.ai", - ".git", "/raw/", # GitHub images ".slack.com", # Slack URLs to private channels "https://maps.app.goo.gl/nxB8YygRQeXSS9G18", # Ultralytics Madrid office - Cra de San Jeronimo 15 @@ -281,6 +280,7 @@ def allow_redirect(start="", end=""): return ( end and end.startswith("https://") + and not start_lower.endswith(".git") # git clone URLs, i.e. https://github.com/org/repo.git and all(item not in end_lower for item in REDIRECT_END_IGNORE_LIST) and all(item not in start_lower for item in REDIRECT_START_IGNORE_LIST) ) diff --git a/tests/test_common_utils.py b/tests/test_common_utils.py index 2fe36d6..ae640aa 100644 --- a/tests/test_common_utils.py +++ b/tests/test_common_utils.py @@ -41,12 +41,19 @@ def test_allow_redirect(): # Should not allow - start ignores assert not allow_redirect("https://youtu.be/xyz", "https://youtube.com") + # Should not allow - git clone URLs + assert not allow_redirect("https://github.com/ultralytics/ultralytics.git", "https://github.com/ultralytics/yolo") + # Should not allow - end ignores assert not allow_redirect("https://example.com", "https://example.com/404") # Empty end URL assert not allow_redirect("https://example.com", "") + # Should allow - GitHub subdomains are not git clone URLs + assert allow_redirect("https://docs.github.com/en/old", "https://docs.github.com/en/new") + assert allow_redirect("https://gist.github.com/user/abc", "https://gist.github.com/user/def") + @patch("requests.get") def test_brave_search(mock_get):