Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
Escape all sources when they need it (#967)
Browse files Browse the repository at this point in the history
The need for escaping doesn't depend on if it's a local (file) or remote (http/s) uri
It depends only on if there is a space in it or not. This can be in either, although it's more likely in a file path with "C:\Program Files" etc
ArgumentEscaper will check for spaces and handle it when needed

Co-authored-by: Anthony Steele <[email protected]>
  • Loading branch information
AnthonySteele and Anthony Steele authored May 7, 2020
1 parent 6ab8956 commit 4d9caad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions NuKeeper.Abstractions/NuGet/NuGetSources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public NuGetSources(IEnumerable<PackageSource> sources)
public string CommandLine(string prefix)
{
return Items
.Select(s => $"{prefix} {EscapePathIfLocal(s)}")
.Select(s => $"{prefix} {EscapeSource(s)}")
.JoinWithSeparator(" ");
}

Expand All @@ -54,9 +54,9 @@ public override string ToString()
return Items.Select(s => s.SourceUri.ToString()).JoinWithCommas();
}

private static string EscapePathIfLocal(PackageSource source)
private static string EscapeSource(PackageSource source)
{
return source.IsLocal ? ArgumentEscaper.EscapeAndConcatenate(new[] { source.Source }) : source.Source;
return ArgumentEscaper.EscapeAndConcatenate(new[] { source.Source });
}
}
}

0 comments on commit 4d9caad

Please sign in to comment.