Skip to content

Commit

Permalink
reject empty readme file & fix error message for invalid extension (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
lyndaidaii committed Apr 1, 2021
1 parent 91c68fe commit b72d197
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/NuGetGallery/Services/PackageMetadataValidationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ private async Task<PackageValidationResult> CheckReadmeMetadataAsync(PackageArch
}

var readmeFileEntry = nuGetPackage.GetEntry(readmeFilePath);

if (readmeFileEntry.Length == 0)
{
return PackageValidationResult.Invalid(
string.Format(
Strings.ReadmeErrorEmpty,
Strings.UploadPackage_ReadmeFileType,
readmeFilePath));
}

if (readmeFileEntry.Length > MaxAllowedReadmeLengthForUploading)
{
return PackageValidationResult.Invalid(
Expand Down
11 changes: 10 additions & 1 deletion src/NuGetGallery/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/NuGetGallery/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1166,7 +1166,7 @@ The {1} Team</value>
<value>The &lt;readme&gt; element is not currently supported.</value>
</data>
<data name="UploadPackage_InvalidReadmeFileExtension" xml:space="preserve">
<value>The readme file has an invalid extension '{0}'. Extension must be one of the following: {1}.</value>
<value>The readme file has an invalid extension '{0}'. The extension must be: '{1}'.</value>
<comment>{0} is the readme file extension specified in the .nuspec, {1} is the list of allowed extensions</comment>
</data>
<data name="UploadPackage_ReadmeFileType" xml:space="preserve">
Expand Down Expand Up @@ -1215,4 +1215,7 @@ The {1} Team</value>
<data name="UploadPackage_OwnerlessIdNamespaceConflictHtml" xml:space="preserve">
<value>The package ID is reserved. You can upload your package with a different package ID. Reach out to &lt;a href="mailto:support@nuget.org"&gt;support@nuget.org&lt;/a&gt; if you have questions.</value>
</data>
<data name="ReadmeErrorEmpty" xml:space="preserve">
<value>The readme file '{0}' cannot be empty.</value>
</data>
</root>

0 comments on commit b72d197

Please sign in to comment.