loic-sharma / BaGet

A lightweight NuGet and symbol server
https://loic-sharma.github.io/BaGet/
MIT License
2.58k stars 644 forks source link

Normalize readme entry path prior to extraction #727

Open SergeyFilippov opened 2 years ago

SergeyFilippov commented 2 years ago

The packages with "\" character in readme node cannot be pushed to BaGet on Linux.

Similar to the issue #517 it is impossible to push a package with "\" character inside of "readme" node of nuspec file.

To Reproduce

Steps to reproduce the behavior:

  1. Using v0.4.0-preview2 version of Baget in docker (sha256:c66780acc1278f7727671e6523a5fc9236b883d430058c6b9a348a2011be8f09)
  2. Trying to push a ZetaLongPath
  3. Error occures:
    BaGet.Core.PackageIndexingService[0]
      Uploaded package is invalid
    System.IO.FileNotFoundException: docs\readme.md
    at NuGet.Packaging.ZipArchiveExtensions.LookupEntry(ZipArchive zipArchive, String path)
    at NuGet.Packaging.ZipArchiveExtensions.OpenFile(ZipArchive zipArchive, String path)
    at NuGet.Packaging.PackageArchiveReader.GetStream(String path)
    at NuGet.Packaging.PackageReaderBase.GetStreamAsync(String path, CancellationToken cancellationToken)
    at BaGet.Core.PackageArchiveReaderExtensions.GetReadmeAsync(PackageArchiveReader package, CancellationToken cancellationToken) in /src/BaGet.Core/Extensions/PackageArchiveReaderExtensions.cs:line 32
    at BaGet.Core.PackageIndexingService.IndexAsync(Stream packageStream, CancellationToken cancellationToken) in /src/BaGet.Core/Indexing/PackageIndexingService.cs:line 56

Expected behavior

It is possible to upload or download this kind of packages.

Nobody84 commented 1 year ago

+1 Have the same issue during Mirroring nuget.org. Looking forward to a fix.

Edit: The fix from @SergeyFilippov (#728) worked for me.

VAllens commented 10 months ago

Is there any progress?

Due to this issue, the package cannot be restored

PeterHagen commented 9 months ago

I currently run into this issue. I found out that, for example, packages mimekit.4.2.0 and mailkit.4.2.0 run into this issues. Therefor I cannot restore my projects in a docker container for deployment anymore.

R4cOOn commented 7 months ago

I use BaGet as a NuGet mirror and I get the same issues when getting some packages from NuGet.
Any alternative Docker image available?

SergeyFilippov commented 7 months ago

I use BaGet as a NuGet mirror and I get the same issues when getting some packages from NuGet. Any alternative Docker image available?

There is a fork, that is fairly maintained and seems to be active with merging pull requests: BaGetter. Last commit is pretty recent and adds dotnet 8 support. There is a docker image for that repo too: Docker image tags

I haven't migrated to it yet, having a locally built image with required fixes, so can't say from experience about it's stability, but the issue with the "readme" paths is solved there.

R4cOOn commented 7 months ago

Thanks for your reply @SergeyFilippov !
I switched my image to theirs and it's working fine.