From c41b30760ba223b8e1db58b1412aacb5e2571b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20Wawrzy=C5=84czyk?= <107928848+fitithw@users.noreply.github.com> Date: Wed, 12 Oct 2022 08:53:56 +0200 Subject: [PATCH] Case-insensitive NuGet symbol file GUID (#21409) NuGet symbol file lookup returned 404 on Visual Studio 2019 due to case-sensitive api router. The api router should accept case-insensitive GUID. Co-authored-by: techknowlogick Co-authored-by: wxiaoguang --- routers/api/packages/api.go | 2 +- routers/api/packages/nuget/nuget.go | 2 +- tests/integration/api_packages_nuget_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/api/packages/api.go b/routers/api/packages/api.go index 0889006dd7..a54add0621 100644 --- a/routers/api/packages/api.go +++ b/routers/api/packages/api.go @@ -196,7 +196,7 @@ func Routes(ctx gocontext.Context) *web.Route { r.Put("/symbolpackage", nuget.UploadSymbolPackage) r.Delete("/{id}/{version}", nuget.DeletePackage) }, reqPackageAccess(perm.AccessModeWrite)) - r.Get("/symbols/{filename}/{guid:[0-9a-f]{32}}FFFFFFFF/{filename2}", nuget.DownloadSymbolFile) + r.Get("/symbols/{filename}/{guid:[0-9a-fA-F]{32}[fF]{8}}/{filename2}", nuget.DownloadSymbolFile) }, reqPackageAccess(perm.AccessModeRead)) }) r.Group("/npm", func() { diff --git a/routers/api/packages/nuget/nuget.go b/routers/api/packages/nuget/nuget.go index eadf7486a5..3c61ae28bb 100644 --- a/routers/api/packages/nuget/nuget.go +++ b/routers/api/packages/nuget/nuget.go @@ -353,7 +353,7 @@ func processUploadedFile(ctx *context.Context, expectedType nuget_module.Package // DownloadSymbolFile https://github.com/dotnet/symstore/blob/main/docs/specs/Simple_Symbol_Query_Protocol.md#request func DownloadSymbolFile(ctx *context.Context) { filename := ctx.Params("filename") - guid := ctx.Params("guid") + guid := ctx.Params("guid")[:32] filename2 := ctx.Params("filename2") if filename != filename2 { diff --git a/tests/integration/api_packages_nuget_test.go b/tests/integration/api_packages_nuget_test.go index 9d53311d35..8d5a5c7c82 100644 --- a/tests/integration/api_packages_nuget_test.go +++ b/tests/integration/api_packages_nuget_test.go @@ -280,7 +280,7 @@ AAAjQmxvYgAAAGm7ENm9SGxMtAFVvPUsPJTF6PbtAAAAAFcVogEJAAAAAQAAAA==`) req = AddBasicAuthHeader(req, user.Name) MakeRequest(t, req, http.StatusNotFound) - req = NewRequest(t, "GET", fmt.Sprintf("%s/symbols/%s/%sFFFFFFFF/%s", url, symbolFilename, symbolID, symbolFilename)) + req = NewRequest(t, "GET", fmt.Sprintf("%s/symbols/%s/%sFFFFffff/%s", url, symbolFilename, symbolID, symbolFilename)) req = AddBasicAuthHeader(req, user.Name) MakeRequest(t, req, http.StatusOK)