Fix repo URL generation to handle GitLab, Bitbucket, SSH, and local repos in the UI - #1783
Fix repo URL generation to handle GitLab, Bitbucket, SSH, and local repos in the UI#1783davidkopp wants to merge 7 commits into
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughFrontend repository links now use a shared helper that normalizes URIs and generates host-specific commit or tree paths. Chart, timeline, and stats rendering conditionally displays links for supported repositories and escapes generated href attributes. Stats relation URLs also fall back to plain text when they are not absolute HTTP(S) URLs. Frontend tests cover multiple repository URI formats and expanded XSS payloads in run data. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: b8dc35cc-cf9a-43c5-ab7b-b19ab114cc42
📒 Files selected for processing (5)
frontend/js/helpers/charts.jsfrontend/js/helpers/main.jsfrontend/js/stats.jsfrontend/js/timeline.jstests/frontend/test_frontend.py
|
@davidkopp dont be startled by the AI reviews. Not everything is relevant. I just triggered it to have more data for a comprehensive manual review tomorrow. First though: thanks for the PR! ❤️ |
ArneTR
left a comment
There was a problem hiding this comment.
The code is very clean and nicely readable.
The refactor is definitely an improvement also. Thanks for that.
I made a remark on some error handling that I found to be a bit harsh. See inline.
Other than that: Please have a look at the CodeRabbit remarks. They look very reasonable.
Would love to bring the PR then in after!
| const cleanUri = toHttpsUri(uri); | ||
| if (!cleanUri.startsWith('http')) return null; | ||
| if (type !== 'commit' && type !== 'tree') { | ||
| throw new Error(`getRepoRefUrl: unknown type '${type}', expected 'commit' or 'tree'`); |
There was a problem hiding this comment.
this feels a bit harsh, as it will block the whole frontend from rendering for code that comes after. Maybe just return a "broken URL" string or something and log error to console.err?
|
I implemented all the comments except the one regarding |
|
Looks good. Running tests and then bringing in :) |
|
Sorry, the tests do not run. GitHub is so slow the last days that the connection to apt package repositories and then after test runs take up to 24 hours to run ... I will try updating the branch to make sure this is not some stale test or caching issue and see again :/ |

Previously, commit and tree URLs were hardcoded to GitHub's
/commit/and/tree/path format. This broke links for:/-/commit/and/-/tree/)/commits/and/src/)git@github.com:org/repo) — not converted to HTTPSfile:///commit/...linksChanges:
getRepoRefUrl(uri, type)infrontend/js/helpers/main.jsthat normalizes URIs to HTTPS and selects the correct path convention per platform (GitHub /commit/, GitLab /-/commit/, Bitbucket /commits/)toHttpsUri(...)/commit/...constructions in charts.js, stats.js, and timeline.js with the new helperbuildCommitLink()function from stats.jsescapeString()for user-controlled URL values interpolated into double-quoted href attributes (stats.js foruri/relations.url/commit_link + commit_hashandmain.js:createExternalIconLink).test_xss_protection_of_run_datato prefix the payload with ">, so it actually breaks out of double-quoted attribute values (closing both the attribute and the surrounding start tag), exercising the href-escaping fixes that the previous plainDisclaimer: I used DeepSeek V4 Flash and GLM 5.2 for this PR.
Summary
hrefattributes to prevent XSS vulnerabilities.buildCommitLink()helper.