Skip to content

Fix missing encoding of project names in urls #1438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Common/AzureDevOps/AzureDevOpsUrlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static bool TryParseHostedHttp(string host, string relativeUrl, [NotNullW
}

projectPath = projectName ?? repositoryName;

if (!isVisualStudioHost)
{
if (teamName != null)
Expand Down Expand Up @@ -106,7 +106,7 @@ public static bool TryParseOnPremHttp(string relativeUrl, string virtualDirector
return false;
}

projectPath = string.Join("/", parts, 0, virtualDirectoryParts.Length) + "/" + collection + "/" + (projectName ?? repositoryName);
projectPath = string.Join("/", parts, 0, virtualDirectoryParts.Length) + "/" + collection + "/" + Uri.EscapeDataString(projectName ?? repositoryName);
return true;
}

Expand Down Expand Up @@ -176,7 +176,7 @@ public static bool TryParseOnPremSsh(Uri uri, [NotNullWhen(true)]out string? rep
repositoryPath = string.Join("/", parts, 0, teamNameIndex + 1);
return true;
}

private static bool TryParsePath(string[] parts, int startIndex, string? type, [NotNullWhen(true)]out string? repositoryPath, [NotNullWhen(true)]out string? repositoryName)
{
if (TryParsePath(parts, startIndex, type, out var projectName, out var teamName, out repositoryName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void TryParseOnPremHttp_Error(string relativeUrl, string virtualDir = "/"
[Theory]
[InlineData("/collection/project/team/_git/repo", "/", "/collection/project", "repo")]
[InlineData("/collection/project/_git/repo", "/", "/collection/project", "repo")]
[InlineData("/collection/project name/_git/repo", "/", "/collection/project%20name", "repo")]
[InlineData("/collection/_git/repo/", "/", "/collection/repo", "repo")]
[InlineData("/collection/_git/repo", "/", "/collection/repo", "repo")]
[InlineData("/virtual/iis/path/collection/project/team/_git/repo", "/virtual/iis/path", "virtual/iis/path/collection/project", "repo")]
Expand Down