fsprojects / fsprojects/Paket

Paket pack doesn't escape square brackets

Open
#3,906 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
F#
Stars
2.1k
Forks
528
Avg merge
1d 12m
Merged PRs (30d)
54

Description

Description

Nuget packages (*.nupkg) conform to the "Open Packaging Concentions", OPC. Thus files within a package are URL-adressed. This also means that reserved chars need to be percent-encoded. For most chars paket pack does the encoding correctly (e.g. a space becomes %20). Square brackets, however, get through unescaped (i.e. [] does not become %5B%5D).

This becomes an issue when processing a nuget package with .NET's OPC API (System.IO.Packaging). If a part contains a square bracket an ArgumentException is thrown, stating that the URI is not valid. And indeed, according to RFC 3986 (cf. very end of Appendix A) square brackets are reserved within a path segment and thus need to be percent-encoded.

Repro steps
  1. Create a paket.template that harvests a directory
  2. ensure there is a file within the harvested dir that contains square brackets (e.g. file[0].txt)
  3. paket pack that template
Expected behavior

The file within the resulting nuget should look like this: file%5B0%5D.txt.

Actual behavior

The file actually looks like this: file[0].txt.

Known workarounds

None I'm aware of.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the paket pack command and reproduce the issue using a harvested file named file[0].txt. Trace how harvested filenames are written into the resulting NuGet package; done means square brackets are percent-encoded as %5B and %5D, and the reproduction no longer produces an invalid OPC part URI.

Written by the indexing model from the issue text.

Assessment

Tech stack
fsharp
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.