From 5a6870a4ac805a2027c0f7c3454528e9cf156809 Mon Sep 17 00:00:00 2001 From: Tomasz Heimowski Date: Mon, 1 Dec 2014 18:00:25 +0100 Subject: [PATCH 1/2] decode uri on createRelativePath --- src/Paket.Core/Utils.fs | 2 +- tests/Paket.Tests/Paket.Tests.fsproj | 1 + tests/Paket.Tests/UtilsSpecs.fs | 9 +++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/Paket.Tests/UtilsSpecs.fs diff --git a/src/Paket.Core/Utils.fs b/src/Paket.Core/Utils.fs index cfc293172d..bbed94d386 100644 --- a/src/Paket.Core/Utils.fs +++ b/src/Paket.Core/Utils.fs @@ -46,7 +46,7 @@ let CleanDir path = /// [omit] let inline createRelativePath root path = let uri = Uri(if String.IsNullOrEmpty root then System.Environment.CurrentDirectory + Path.DirectorySeparatorChar.ToString() else root) - uri.MakeRelativeUri(Uri(path)).ToString().Replace("/", "\\") + uri.MakeRelativeUri(Uri(path)).ToString().Replace("/", "\\") |> Uri.UnescapeDataString /// [omit] let inline normalizeXml(doc:XmlDocument) = diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 2d0adda0bd..94cf149912 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -75,6 +75,7 @@ + Always diff --git a/tests/Paket.Tests/UtilsSpecs.fs b/tests/Paket.Tests/UtilsSpecs.fs new file mode 100644 index 0000000000..074471ac09 --- /dev/null +++ b/tests/Paket.Tests/UtilsSpecs.fs @@ -0,0 +1,9 @@ +module Paket.UtilsSpecs + +open Paket +open NUnit.Framework +open FsUnit + +[] +let ``createRelativePath should handle spaces``() = + "C:/some file" |> createRelativePath "C:/a/b" |> shouldEqual "..\\some file" \ No newline at end of file From 2eabf1cffa6aa3004f8c11b6392bdaf62bffcf0a Mon Sep 17 00:00:00 2001 From: Tomasz Heimowski Date: Mon, 1 Dec 2014 18:05:51 +0100 Subject: [PATCH 2/2] unescape extracted file names from nupkg - references #411 --- src/Paket.Core/NuGetV2.fs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Paket.Core/NuGetV2.fs b/src/Paket.Core/NuGetV2.fs index 7902b31cfa..88645c4938 100644 --- a/src/Paket.Core/NuGetV2.fs +++ b/src/Paket.Core/NuGetV2.fs @@ -289,6 +289,9 @@ let ExtractPackage(fileName:string, targetFolder, name, version:SemVerInfo) = for e in zip do try e.Extract(targetFolder, ExtractExistingFileAction.OverwriteSilently) + let unescapedName = Uri.UnescapeDataString e.FileName + if unescapedName <> e.FileName then + File.Move(Path.Combine(targetFolder, e.FileName), Path.Combine(targetFolder, unescapedName)) with | exn -> failwithf "Error during unzipping %s in %s %A: %s" e.FileName name version exn.Message