From 4e4f12ba9f64013609d449976616e5c7f38385b0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 02:19:09 +0000 Subject: [PATCH] Add regression test for #3906: verify square brackets are escaped in nupkg entries Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Paket.Tests/Packaging/NupkgWriterSpecs.fs | 39 +++++++++++++++++++ tests/Paket.Tests/Paket.Tests.fsproj | 1 + 2 files changed, 40 insertions(+) create mode 100644 tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs diff --git a/tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs b/tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs new file mode 100644 index 0000000000..7dc66358dd --- /dev/null +++ b/tests/Paket.Tests/Packaging/NupkgWriterSpecs.fs @@ -0,0 +1,39 @@ +module Paket.NupkgWriter.Test + +open System.IO +open System.IO.Compression +open Paket +open FsUnit +open NUnit.Framework + +[] +let ``#3906 paket pack escapes square brackets in file names``() = + let workingDir = Path.Combine(Path.GetTempPath(), "paket-nupkgwriter-test-" + System.Guid.NewGuid().ToString("N")) + let outputDir = Path.Combine(workingDir, "out") + let harvestDir = Path.Combine(workingDir, "harvest") + Directory.CreateDirectory harvestDir |> ignore + Directory.CreateDirectory outputDir |> ignore + try + let bracketFile = Path.Combine(harvestDir, "file[0].txt") + File.WriteAllText(bracketFile, "content") + + let core : CompleteCoreInfo = + { Id = "Test.Package" + Version = Some (SemVer.Parse "1.0.0") + Authors = ["Author"] + Description = "Description" + Symbols = false } + + let optional = + { OptionalPackagingInfo.Empty with + Files = ["harvest", "lib/net461"] } + + let outputPath = NupkgWriter.Write core optional workingDir outputDir + + use archive = ZipFile.OpenRead outputPath + let entryNames = archive.Entries |> Seq.map (fun e -> e.FullName) |> Seq.toList + + entryNames |> shouldContain "lib/net461/file%5B0%5D.txt" + entryNames |> List.contains "lib/net461/file[0].txt" |> shouldEqual false + finally + if Directory.Exists workingDir then Directory.Delete(workingDir, true) diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 832e4e2a91..2ec87e8825 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -206,6 +206,7 @@ +