Fix crash adding repos with dots in shorthand (e.g. mono/SkiaSharp.Extended)#256
Merged
Fix crash adding repos with dots in shorthand (e.g. mono/SkiaSharp.Extended)#256
Conversation
…tended) NormalizeRepoUrl rejected GitHub shorthand containing dots, passing the raw string to RepoIdFromUrl which threw on new Uri(). Two fixes: names are common) - Use Uri.TryCreate instead of new Uri() with a fallback for robustness Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
StephaneDelcroix
left a comment
There was a problem hiding this comment.
Findings
🟡 MODERATE -- RepoManagerTests.cs:58 -- Stale test assertion (4/5 models)
NormalizeRepoUrl_NonShorthand_PassesThrough("owner/repo.js") now fails because removing !input.Contains('.') causes owner/repo.js to match shorthand and expand to https://github.com/owner/repo.js. Move this case to NormalizeRepoUrl_Shorthand_ExpandsToGitHub.
🟡 MODERATE -- RepoManager.cs:299 -- Bare hostnames false-positive as GitHub shorthand (3/5 models)
Removing the dot guard means inputs like gitlab.com/myrepo expand to https://github.com/gitlab.com/myrepo. Fix: scope guard to owner segment only (!parts[0].Contains('.') ).
RepoIdFromUrl hardening (Uri.TryCreate + fallback) is clean.
Action: ⚠️ Request changes
- Update the stale test case
- Scope dot guard to owner segment only
…s while rejecting hostnames Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Adding a repo via GitHub shorthand with dots in the name (e.g.
mono/SkiaSharp.Extended) crashes withInvalid URIbecause:2.
RepoIdFromUrlusesnew Uri()which throws on non-URL stringsFix
Uri.TryCreatewith a fallback instead ofnew Uri()for robustnessTesting
Verified
mono/SkiaSharp.Extendedclones successfully after the fix.