diff --git a/src/NuGetGallery.Core/Infrastructure/TableErrorLog.cs b/src/NuGetGallery.Core/Infrastructure/TableErrorLog.cs index 314f16a220..8cefe9c7f1 100644 --- a/src/NuGetGallery.Core/Infrastructure/TableErrorLog.cs +++ b/src/NuGetGallery.Core/Infrastructure/TableErrorLog.cs @@ -186,7 +186,7 @@ public override string Log(Error error) return pos.ToString(CultureInfo.InvariantCulture); } - private void Obfuscate(Error error) + public static void Obfuscate(Error error) { error.User = string.Empty; if (error.Form != null) @@ -218,10 +218,19 @@ private void Obfuscate(Error error) error.ServerVariables["HTTP_X_NUGET_APIKEY"] = string.Empty; - var forwardedIps = error.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(','); - var obfuscatedIps = forwardedIps.Select(Obfuscator.ObfuscateIp); - - error.ServerVariables["HTTP_X_FORWARDED_FOR"] = string.Join(",", obfuscatedIps); + var forwardedIps = error.ServerVariables["HTTP_X_FORWARDED_FOR"]? + .Split(',') + .Select(x => x.Trim()) + .Where(x => x.Length > 0) + .ToList(); + if (forwardedIps != null) + { + var obfuscatedIps = string.Join(",", forwardedIps.Select(Obfuscator.ObfuscateIp)); + if (!string.IsNullOrWhiteSpace(obfuscatedIps)) + { + error.ServerVariables["HTTP_X_FORWARDED_FOR"] = obfuscatedIps; + } + } } } } \ No newline at end of file diff --git a/src/NuGetGallery/App_Code/ViewHelpers.cshtml b/src/NuGetGallery/App_Code/ViewHelpers.cshtml index e86bd2b4bf..b15da2a79a 100644 --- a/src/NuGetGallery/App_Code/ViewHelpers.cshtml +++ b/src/NuGetGallery/App_Code/ViewHelpers.cshtml @@ -577,8 +577,8 @@ var hlp = new AccordionHelper(name, formModelStatePrefix, expanded, page); if (!disabled) { -
+
@content(MvcHtmlString.Empty)
diff --git a/src/NuGetGallery/Scripts/gallery/page-list-packages.js b/src/NuGetGallery/Scripts/gallery/page-list-packages.js index 640c76ca60..c3e682f196 100644 --- a/src/NuGetGallery/Scripts/gallery/page-list-packages.js +++ b/src/NuGetGallery/Scripts/gallery/page-list-packages.js @@ -2,7 +2,6 @@ $(function() { 'use strict'; $(".reserved-indicator").each(window.nuget.setPopovers); - $(".framework-filter-info-icon").each(window.nuget.setPopovers); const searchForm = document.forms.search; const allFrameworks = document.querySelectorAll('.framework'); diff --git a/src/NuGetGallery/Strings.Designer.cs b/src/NuGetGallery/Strings.Designer.cs index eb6aaf6c4b..f2e548d328 100644 --- a/src/NuGetGallery/Strings.Designer.cs +++ b/src/NuGetGallery/Strings.Designer.cs @@ -1102,15 +1102,6 @@ public static string ForgotPassword_Disabled_Error { } } - /// - /// Looks up a localized string similar to Filters packages based on the target frameworks included in the NuGet Package.. - /// - public static string FrameworkFilterInformation_Tooltip { - get { - return ResourceManager.GetString("FrameworkFilterInformation_Tooltip", resourceCulture); - } - } - /// /// Looks up a localized string similar to The API key '{0}' is invalid.. /// diff --git a/src/NuGetGallery/Strings.resx b/src/NuGetGallery/Strings.resx index f515658d62..f337eccb71 100644 --- a/src/NuGetGallery/Strings.resx +++ b/src/NuGetGallery/Strings.resx @@ -1254,7 +1254,4 @@ The {1} Team Forgot password is disabled. - - Filters packages based on the target frameworks included in the NuGet Package. - \ No newline at end of file diff --git a/src/NuGetGallery/ViewModels/PackageListViewModel.cs b/src/NuGetGallery/ViewModels/PackageListViewModel.cs index 1e1f5ca0fd..512d30e07b 100644 --- a/src/NuGetGallery/ViewModels/PackageListViewModel.cs +++ b/src/NuGetGallery/ViewModels/PackageListViewModel.cs @@ -84,6 +84,6 @@ public PackageListViewModel( public Dictionary FrameworkFilters = FrameworkFilterHelper.FrameworkFilters; - public string TargetFrameworkInformationLink = "https://learn.microsoft.com/en-us/dotnet/standard/frameworks"; + public string FrameworksFilteringInformationLink = "https://learn.microsoft.com/nuget/consume-packages/finding-and-choosing-packages#advanced-filtering-and-sorting"; } } \ No newline at end of file diff --git a/src/NuGetGallery/Views/Organizations/_OrganizationAccountManageMembers.cshtml b/src/NuGetGallery/Views/Organizations/_OrganizationAccountManageMembers.cshtml index ef11cd7c43..f3a4bdcddc 100644 --- a/src/NuGetGallery/Views/Organizations/_OrganizationAccountManageMembers.cshtml +++ b/src/NuGetGallery/Views/Organizations/_OrganizationAccountManageMembers.cshtml @@ -68,18 +68,7 @@
-
- -
- - - -
- -
-
+
@if (Model.CanManageMemberships) { @@ -93,6 +82,17 @@ }
+
+ +
+ + + +
+ +
diff --git a/src/NuGetGallery/Views/Shared/ListPackages.cshtml b/src/NuGetGallery/Views/Shared/ListPackages.cshtml index 294e771d32..c603f55c1e 100644 --- a/src/NuGetGallery/Views/Shared/ListPackages.cshtml +++ b/src/NuGetGallery/Views/Shared/ListPackages.cshtml @@ -82,10 +82,8 @@
Frameworks - - + + @foreach (var framework in Model.FrameworkFilters.Values) diff --git a/src/NuGetGallery/Views/Shared/_ListPackage.cshtml b/src/NuGetGallery/Views/Shared/_ListPackage.cshtml index e5ee0838a8..3eb2c2f428 100644 --- a/src/NuGetGallery/Views/Shared/_ListPackage.cshtml +++ b/src/NuGetGallery/Views/Shared/_ListPackage.cshtml @@ -126,7 +126,7 @@ @Model.ShortDescription @if (Model.IsDescriptionTruncated) { - @Html.RouteLink("More information", RouteName.DisplayPackage, new { Model.Id, Model.Version }) + @Html.RouteLink("More information", RouteName.DisplayPackage, new { Model.Id, Model.Version }, new { @title = "More information about " + Model.Id + " package." }) } diff --git a/src/NuGetGallery/Views/Users/ApiKeys.cshtml b/src/NuGetGallery/Views/Users/ApiKeys.cshtml index 21c8d611dc..f663a65efe 100644 --- a/src/NuGetGallery/Views/Users/ApiKeys.cshtml +++ b/src/NuGetGallery/Views/Users/ApiKeys.cshtml @@ -336,8 +336,7 @@
- Select Scopes -
+

Select Scopes

@@ -394,7 +393,7 @@
- Select Packages +

Select Packages

To select which packages to associate with a key, use a glob pattern, select individual packages, or both. diff --git a/src/NuGetGallery/Views/Users/Organizations.cshtml b/src/NuGetGallery/Views/Users/Organizations.cshtml index e869b74064..70ec8d2579 100644 --- a/src/NuGetGallery/Views/Users/Organizations.cshtml +++ b/src/NuGetGallery/Views/Users/Organizations.cshtml @@ -12,7 +12,7 @@ Url, CurrentUser, false, - @Organizations   Add new) + @Organizations   Add new)

diff --git a/tests/NuGetGallery.Core.Facts/Infrastructure/TableErrorLogFacts.cs b/tests/NuGetGallery.Core.Facts/Infrastructure/TableErrorLogFacts.cs new file mode 100644 index 0000000000..31bf7d1aae --- /dev/null +++ b/tests/NuGetGallery.Core.Facts/Infrastructure/TableErrorLogFacts.cs @@ -0,0 +1,48 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using Elmah; +using Xunit; + +namespace NuGetGallery.Infrastructure +{ + public class TableErrorLogFacts + { + public class TheObfuscateMethod + { + [Fact] + public void HandlesMissingForwardedHeader() + { + // Arrange + var error = new Error(); + + // Act + TableErrorLog.Obfuscate(error); + + // Assert + Assert.DoesNotContain("HTTP_X_FORWARDED_FOR", error.ServerVariables.Keys.Cast()); + } + + [Theory] + [InlineData("", "")] + [InlineData(",", ",")] + [InlineData(" ", " ")] + [InlineData("127.0.0.1", "127.0.0.0")] + [InlineData("127.1.2.3,127.1.2.4", "127.1.2.0,127.1.2.0")] + [InlineData("127.1.2.3 , 127.1.2.4", "127.1.2.0,127.1.2.0")] + public void ObfuscatesForwardedHeader(string input, string expected) + { + // Arrange + var error = new Error(); + error.ServerVariables["HTTP_X_FORWARDED_FOR"] = input; + + // Act + TableErrorLog.Obfuscate(error); + + // Assert + Assert.Equal(expected, error.ServerVariables["HTTP_X_FORWARDED_FOR"]); + } + } + } +} diff --git a/tests/NuGetGallery.Core.Facts/NuGetGallery.Core.Facts.csproj b/tests/NuGetGallery.Core.Facts/NuGetGallery.Core.Facts.csproj index a72654dc5e..b208be8933 100644 --- a/tests/NuGetGallery.Core.Facts/NuGetGallery.Core.Facts.csproj +++ b/tests/NuGetGallery.Core.Facts/NuGetGallery.Core.Facts.csproj @@ -98,6 +98,7 @@ +