Skip to content

Commit e42da10

Browse files
committed
Limit release notes to 35000 characters (#6720)
Address NuGet/Engineering#1953
1 parent 7ed3e70 commit e42da10

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/NuGetGallery/Helpers/PackageHelper.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ public static void ValidateNuGetPackageMetadata(PackageMetadata packageMetadata)
109109
{
110110
throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Summary", "4000");
111111
}
112+
if (packageMetadata.ReleaseNotes != null && packageMetadata.ReleaseNotes.Length > 35000)
113+
{
114+
throw new EntityException(Strings.NuGetPackagePropertyTooLong, "ReleaseNotes", "35000");
115+
}
112116
if (packageMetadata.Tags != null && packageMetadata.Tags.Length > 4000)
113117
{
114118
throw new EntityException(Strings.NuGetPackagePropertyTooLong, "Tags", "4000");

tests/NuGetGallery.Facts/Services/PackageServiceFacts.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,17 @@ private async Task WillThrowIfTheNuGetPackageCopyrightIsLongerThan4000()
543543
Assert.Equal(String.Format(Strings.NuGetPackagePropertyTooLong, "Copyright", "4000"), ex.Message);
544544
}
545545

546+
[Fact]
547+
private async Task WillThrowIfTheNuGetPackageReleaseNotesIsLongerThan35000()
548+
{
549+
var service = CreateService();
550+
var nugetPackage = PackageServiceUtility.CreateNuGetPackage(releaseNotes: "theReleaseNotes".PadRight(35001, '_'));
551+
552+
var ex = await Assert.ThrowsAsync<InvalidPackageException>(async () => await service.CreatePackageAsync(nugetPackage.Object, new PackageStreamMetadata(), owner: null, currentUser: null, isVerified: false));
553+
554+
Assert.Equal(String.Format(Strings.NuGetPackagePropertyTooLong, "ReleaseNotes", "35000"), ex.Message);
555+
}
556+
546557
[Fact]
547558
private async Task WillThrowIfTheVersionIsLongerThan64Characters()
548559
{

0 commit comments

Comments
 (0)