diff --git a/src/chocolatey/StringExtensions.cs b/src/chocolatey/StringExtensions.cs
index c9a638a939..8bc60fe3c6 100644
--- a/src/chocolatey/StringExtensions.cs
+++ b/src/chocolatey/StringExtensions.cs
@@ -195,5 +195,20 @@ public static string escape_curly_braces(this string input)
return open_brace_regex.Replace(close_brace_regex.Replace(input,"}}"),"{{");
}
+
+ ///
+ /// Surrounds with quotes if a pipe is found in the input string.
+ ///
+ /// The input.
+ /// The input, but with double quotes if there is a pipe character found in the string.
+ public static string quote_if_pipe_found(this string input)
+ {
+ if (string.IsNullOrWhiteSpace(input)) return input.to_string();
+
+ if (input.contains("|")) return "\"{0}\"".format_with(input);
+
+ return input;
+ }
+
}
}
\ No newline at end of file
diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs
index da81ed6a48..14fb95ee4b 100644
--- a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs
+++ b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs
@@ -78,7 +78,7 @@ public virtual IEnumerable source_list(ChocolateyConfiguration
source.Id,
source.Value,
source.Disabled.to_string(),
- source.UserName,
+ source.UserName.quote_if_pipe_found(),
source.Certificate,
source.Priority,
source.BypassProxy.to_string(),