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:
¨NW¨
2026-04-19 12:17:53 +01:00
parent 7523911812
commit 573d9a641e
11 changed files with 16 additions and 16 deletions

View File

@@ -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}" \