Skip to content

Commit

Permalink
Fix code scanning alert no. 1: Incomplete URL substring sanitization
Browse files Browse the repository at this point in the history
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
gagb and github-advanced-security[bot] authored Dec 13, 2024
1 parent 7979eec commit 778fca3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/markitdown/_markitdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -967,11 +967,13 @@ def convert(
- extension: specifies the file extension to use when interpreting the file. If None, infer from source (path, uri, content-type, etc.)
"""
# Handle GitHub issue URLs directly
if isinstance(source, str) and "github.com" in source and "/issues/" in source:
github_token = kwargs.get("github_token", os.getenv("GITHUB_TOKEN"))
if not github_token:
raise ValueError("GitHub token is required for GitHub issue conversion.")
return GitHubIssueConverter().convert(issue_url=source, github_token=github_token)
if isinstance(source, str):
parsed_url = urlparse(source)
if parsed_url.hostname == "github.com" and "/issues/" in parsed_url.path:
github_token = kwargs.get("github_token", os.getenv("GITHUB_TOKEN"))
if not github_token:
raise ValueError("GitHub token is required for GitHub issue conversion.")
return GitHubIssueConverter().convert(issue_url=source, github_token=github_token)

# Local path or url
if isinstance(source, str):
Expand Down

0 comments on commit 778fca3

Please sign in to comment.