Skip to content

Commit ad08cb4

Browse files
committed
Fix tests
1 parent 38936f7 commit ad08cb4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/sagemaker/git_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def _sanitize_git_url(repo_url):
5252
if at_count > 1:
5353
raise ValueError("Invalid HTTPS URL format: multiple @ symbols detected")
5454

55+
# Check for invalid characters in the URL before parsing
56+
# These characters should not appear in legitimate URLs
57+
invalid_chars = ["<", ">", "[", "]", "{", "}", "\\", "^", "`", "|"]
58+
for char in invalid_chars:
59+
if char in repo_url:
60+
raise ValueError("Invalid characters in hostname")
61+
5562
try:
5663
parsed = urlparse(repo_url)
5764

tests/unit/test_estimator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2794,7 +2794,7 @@ def test_git_support_bad_repo_url_format(sagemaker_session):
27942794
)
27952795
with pytest.raises(ValueError) as error:
27962796
fw.fit()
2797-
assert "Invalid Git url provided." in str(error)
2797+
assert "Unsupported URL scheme" in str(error)
27982798

27992799

28002800
@patch(

0 commit comments

Comments
 (0)