fix(security): add rstrip('/') to get_target_repo for trailing-slash URLs
The regex r'[:/]([^/]+/[^/]+?)(?:\.git)?$' fails on URLs with trailing slashes like 'https://git.softuniq.eu/UniqueSoft/APAW/' because the final '/' breaks the pattern. Added .rstrip('/') in Python and sed 's:/*' in Bash to all get_target_repo() implementations across 11 files.
This commit is contained in:
@@ -17,7 +17,7 @@ def get_target_repo():
|
||||
['git', 'remote', 'get-url', 'origin'],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
remote_url = result.stdout.strip()
|
||||
remote_url = result.stdout.strip().rstrip('/')
|
||||
|
||||
# HTTPS: https://git.softuniq.eu/Owner/Repo.git
|
||||
# SSH: git@git.softuniq.eu:Owner/Repo.git
|
||||
@@ -51,7 +51,7 @@ def get_target_repo():
|
||||
['git', 'remote', 'get-url', 'origin'],
|
||||
capture_output=True, text=True
|
||||
)
|
||||
remote_url = result.stdout.strip()
|
||||
remote_url = result.stdout.strip().rstrip('/')
|
||||
match = re.search(r'[:/]([^/]+/[^/]+?)(?:\.git)?$', remote_url)
|
||||
if match:
|
||||
return match.group(1)
|
||||
@@ -89,7 +89,7 @@ def create_issue(title, body, labels=None, repo=None):
|
||||
|
||||
```bash
|
||||
# Auto-detect target repo
|
||||
TARGET_REPO=$(git remote get-url origin | sed -E 's|.*[:/]([^/]+/[^/]+?)(\.git)?$|\1|')
|
||||
TARGET_REPO=$(git remote get-url origin | sed 's:/*$::' | sed -E 's|.*[:/]([^/]+/[^/]+?)(\.git)?$|\1|')
|
||||
|
||||
# Post comment
|
||||
curl -X POST -H "Authorization: token ${GITEA_TOKEN}" \
|
||||
|
||||
Reference in New Issue
Block a user