mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix use of Start-Process http://bing.com (#9793)
This commit is contained in:
@@ -460,7 +460,7 @@ namespace System.Management.Automation
|
||||
// Try literal path resolution if it is set to run first
|
||||
if (_commandResolutionOptions.HasFlag(SearchResolutionOptions.ResolveLiteralThenPathPatterns))
|
||||
{
|
||||
var path = GetNextLiteralPathThatExists(_commandName, out _);
|
||||
var path = GetNextLiteralPathThatExistsAndHandleExceptions(_commandName, out _);
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
@@ -478,7 +478,7 @@ namespace System.Management.Automation
|
||||
if (!_commandResolutionOptions.HasFlag(SearchResolutionOptions.ResolveLiteralThenPathPatterns) &&
|
||||
resolvedPaths.Count == 0)
|
||||
{
|
||||
string path = GetNextLiteralPathThatExists(_commandName, out _);
|
||||
string path = GetNextLiteralPathThatExistsAndHandleExceptions(_commandName, out _);
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
@@ -1222,6 +1222,68 @@ namespace System.Management.Automation
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the next literal path.
|
||||
/// Filtering to ones that exist for the filesystem.
|
||||
/// Handles Exceptions
|
||||
/// </summary>
|
||||
/// <param name="command">
|
||||
/// The command to search for.
|
||||
/// </param>
|
||||
/// <param name="provider">The provider that the command was found in.</param>
|
||||
/// <returns>
|
||||
/// Full path to the command.
|
||||
/// </returns>
|
||||
private string GetNextLiteralPathThatExistsAndHandleExceptions(string command, out ProviderInfo provider)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetNextLiteralPathThatExists(command, out provider);
|
||||
}
|
||||
catch (ItemNotFoundException)
|
||||
{
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"The path could not be found: {0}",
|
||||
_commandName);
|
||||
}
|
||||
catch (DriveNotFoundException)
|
||||
{
|
||||
// This can be because we think a scope or a url is a drive
|
||||
// and need to continue searching.
|
||||
// Although, scope does not work through get-command
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"A drive could not be found for the path: {0}",
|
||||
_commandName);
|
||||
}
|
||||
catch (ProviderNotFoundException)
|
||||
{
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"A provider could not be found for the path: {0}",
|
||||
_commandName);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"The path specified a home directory, but the provider home directory was not set. {0}",
|
||||
_commandName);
|
||||
}
|
||||
catch (ProviderInvocationException providerException)
|
||||
{
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"The provider associated with the path '{0}' encountered an error: {1}",
|
||||
_commandName,
|
||||
providerException.Message);
|
||||
}
|
||||
catch (PSNotSupportedException)
|
||||
{
|
||||
CommandDiscovery.discoveryTracer.TraceError(
|
||||
"The provider associated with the path '{0}' does not implement ContainerCmdletProvider",
|
||||
_commandName);
|
||||
}
|
||||
|
||||
provider = null;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the next literal path.
|
||||
|
||||
Reference in New Issue
Block a user