|
7 | 7 | using System.Data.SqlClient; |
8 | 8 | using System.IO; |
9 | 9 | using System.Linq; |
| 10 | +using System.Net; |
10 | 11 | using System.Threading; |
11 | 12 | using System.Threading.Tasks; |
12 | 13 | using System.Xml.Linq; |
@@ -170,6 +171,7 @@ private async Task<PackageValidationResult> CheckLicenseMetadataAsync(PackageArc |
170 | 171 | var licenseUrl = nuspecReader.GetLicenseUrl(); |
171 | 172 | var licenseMetadata = nuspecReader.GetLicenseMetadata(); |
172 | 173 | var licenseDeprecationUrl = GetExpectedLicenseUrl(licenseMetadata); |
| 174 | + var alternativeDeprecationUrl = GetExpectedAlternativeUrl(licenseMetadata); |
173 | 175 |
|
174 | 176 | if (licenseMetadata == null) |
175 | 177 | { |
@@ -217,7 +219,7 @@ private async Task<PackageValidationResult> CheckLicenseMetadataAsync(PackageArc |
217 | 219 | string.Join(" ", licenseMetadata.WarningsAndErrors))); |
218 | 220 | } |
219 | 221 |
|
220 | | - if (licenseDeprecationUrl != licenseUrl) |
| 222 | + if (licenseDeprecationUrl != licenseUrl && (alternativeDeprecationUrl == null || alternativeDeprecationUrl != licenseUrl)) |
221 | 223 | { |
222 | 224 | if (licenseMetadata.Type == LicenseType.File) |
223 | 225 | { |
@@ -378,6 +380,25 @@ private static string GetExpectedLicenseUrl(LicenseMetadata licenseMetadata) |
378 | 380 | throw new InvalidOperationException($"Unsupported license metadata type: {licenseMetadata.Type}"); |
379 | 381 | } |
380 | 382 |
|
| 383 | + /// <summary> |
| 384 | + /// 15.9 client does url encoding with <see cref="WebUtility.UrlEncode(string)"/> which |
| 385 | + /// replaces spaces with "+". We shouldn't work about it, but we should fix the client, |
| 386 | + /// too. |
| 387 | + /// </summary> |
| 388 | + private static string GetExpectedAlternativeUrl(LicenseMetadata licenseMetadata) |
| 389 | + { |
| 390 | + if (licenseMetadata != null && licenseMetadata.Type == LicenseType.Expression) |
| 391 | + { |
| 392 | + return new Uri( |
| 393 | + string.Format( |
| 394 | + LicenseExpressionRedirectUrlHelper.LicenseExpressionDeprecationUrlFormat, |
| 395 | + WebUtility.UrlEncode(licenseMetadata.License))) |
| 396 | + .AbsoluteUri; |
| 397 | + } |
| 398 | + |
| 399 | + return null; |
| 400 | + } |
| 401 | + |
381 | 402 | private static bool HasChildElements(XElement xElement) |
382 | 403 | => xElement.Elements().Any(); |
383 | 404 |
|
|
0 commit comments