From 458c6e9a84981b9cfbd791daf05d9d7883a3f830 Mon Sep 17 00:00:00 2001 From: Anthony Steele Date: Wed, 6 May 2020 16:40:55 +0100 Subject: [PATCH] Escape all sources when they need it 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 --- NuKeeper.Abstractions/NuGet/NuGetSources.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/NuKeeper.Abstractions/NuGet/NuGetSources.cs b/NuKeeper.Abstractions/NuGet/NuGetSources.cs index 3f61d2fe1..a215060b2 100644 --- a/NuKeeper.Abstractions/NuGet/NuGetSources.cs +++ b/NuKeeper.Abstractions/NuGet/NuGetSources.cs @@ -45,7 +45,7 @@ public NuGetSources(IEnumerable sources) public string CommandLine(string prefix) { return Items - .Select(s => $"{prefix} {EscapePathIfLocal(s)}") + .Select(s => $"{prefix} {EscapeSource(s)}") .JoinWithSeparator(" "); } @@ -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 }); } } }