Skip to content

Commit

Permalink
Merge pull request #412 from theimowski/encoded_space_in_library_file…
Browse files Browse the repository at this point in the history
…name

Unescape library filename
  • Loading branch information
forki committed Dec 1, 2014
2 parents 57d6303 + 2eabf1c commit a124add
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Paket.Core/NuGetV2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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) =
Expand Down
1 change: 1 addition & 0 deletions tests/Paket.Tests/Paket.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
<Compile Include="NugetVersionRangeParserSpecs.fs" />
<Compile Include="NugetVersionRangeSerializerSpecs.fs" />
<Compile Include="BindingRedirect.fs" />
<Compile Include="UtilsSpecs.fs" />
<Content Include="Nuspec\FSharp.Data.nuspec">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand Down
9 changes: 9 additions & 0 deletions tests/Paket.Tests/UtilsSpecs.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Paket.UtilsSpecs

open Paket
open NUnit.Framework
open FsUnit

[<Test>]
let ``createRelativePath should handle spaces``() =
"C:/some file" |> createRelativePath "C:/a/b" |> shouldEqual "..\\some file"

0 comments on commit a124add

Please sign in to comment.