Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
190c99a
Remove FormObject.cs and FormObjectCollection.cs (#19383)
CarloToso Mar 21, 2023
18f0c5a
Exclude redundant parameter aliases from completion results (#19382)
MartinGC94 Mar 22, 2023
098be48
Revert "Remove FormObject.cs and FormObjectCollection.cs (#19383)" (#…
CarloToso Mar 22, 2023
48c9d68
Add the parameter `-RelativeBasePath` to `Resolve-Path` (#19358)
MartinGC94 Mar 22, 2023
25651ef
Fix a crash in the type inference code (#19400)
MartinGC94 Mar 23, 2023
fc918bc
Remove GetResponseObject (#19380)
CarloToso Mar 24, 2023
2553a56
Add `-Environment` parameter to `Start-Process` (#19374)
SteveL-MSFT Mar 27, 2023
37c6166
Add PoolNames variable group to compliance pipeline (#19408)
TravisEz13 Mar 27, 2023
7ee2206
Improve package management acceptance tests by not going to the galle…
JamesWTruher Mar 27, 2023
5a22587
Skip VT100 tests on Windows Server 2012R2 as console does not support…
adityapatwardhan Mar 28, 2023
51f55f7
Update the `ICommandPredictor` interface to reduce boilerplate code f…
daxian-dbw Mar 29, 2023
04b93af
Enable type conversion of `AutomationNull` to `$null` for assignment …
SteveL-MSFT Apr 3, 2023
7c0fe76
Remove code related to `#requires -pssnapin` (#19320)
SteveL-MSFT Apr 3, 2023
17fb783
Support CTRL-C when reading data and connection hangs for `Invoke-Res…
stevenebutler Apr 3, 2023
6530133
Update to the latest NOTICES file (#19332)
pwshBot Apr 5, 2023
0ddb187
Update the cgmanifest (#19459)
pwshBot Apr 5, 2023
059b952
WIP: Harden default command test. (#19416)
JamesWTruher Apr 6, 2023
32ee85b
Merge remote-tracking branch 'origin/master' into pr/19379
stevenebutler Apr 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions ThirdPartyNotices.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,24 @@ limitations under the License.

---------------------------------------------------------

Markdig.Signed 0.31.0 - BSD-2-Clause



Copyright (c) <year> <owner> . All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

---------------------------------------------------------

---------------------------------------------------------

Microsoft.ApplicationInsights 2.21.0 - MIT


Expand Down Expand Up @@ -218,6 +236,48 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


---------------------------------------------------------

---------------------------------------------------------

Microsoft.CodeAnalysis.Common 4.5.0 - MIT


(c) Microsoft Corporation
Copyright (c) .NET Foundation and Contributors

MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---------------------------------------------------------

---------------------------------------------------------

Microsoft.CodeAnalysis.CSharp 4.5.0 - MIT


(c) Microsoft Corporation
Copyright (c) Microsoft Corporation
Copyright (c) .NET Foundation and Contributors
Copyright (c) Microsoft Corporation. Alle Rechte

MIT License

Copyright (c) <year> <copyright holders>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---------------------------------------------------------

---------------------------------------------------------
Expand Down Expand Up @@ -3682,6 +3742,42 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


---------------------------------------------------------

---------------------------------------------------------

System.ServiceModel.NetFramingBase 6.0.0-preview1.23060.3 - MIT


(c) Microsoft Corporation
Copyright (c) .NET Foundation and Contributors
Copyright (c) 2000-2014 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org)

The MIT License (MIT)

Copyright (c) .NET Foundation and Contributors

All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


---------------------------------------------------------

---------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1823,6 +1823,26 @@ public SwitchParameter UseNewEnvironment

private SwitchParameter _UseNewEnvironment;

/// <summary>
/// Gets or sets the environment variables for the process.
/// </summary>
[Parameter]
public Hashtable Environment
{
get
{
return _environment;
}

set
{
_environment = value;
_isDefaultSetParameterSpecified = true;
}
}

private Hashtable _environment;

#endregion

#region overrides
Expand Down Expand Up @@ -1929,8 +1949,13 @@ protected override void BeginProcessing()
if (_UseNewEnvironment)
{
startInfo.EnvironmentVariables.Clear();
LoadEnvironmentVariable(startInfo, Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine));
LoadEnvironmentVariable(startInfo, Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User));
LoadEnvironmentVariable(startInfo, System.Environment.GetEnvironmentVariables(EnvironmentVariableTarget.Machine));
LoadEnvironmentVariable(startInfo, System.Environment.GetEnvironmentVariables(EnvironmentVariableTarget.User));
}

if (_environment != null)
{
LoadEnvironmentVariable(startInfo, _environment);
}

startInfo.WindowStyle = _windowstyle;
Expand Down Expand Up @@ -2176,13 +2201,20 @@ private static void LoadEnvironmentVariable(ProcessStartInfo startinfo, IDiction
processEnvironment.Remove(entry.Key.ToString());
}

if (entry.Key.ToString().Equals("PATH"))
if (entry.Value != null)
{
processEnvironment.Add(entry.Key.ToString(), Environment.GetEnvironmentVariable(entry.Key.ToString(), EnvironmentVariableTarget.Machine) + ";" + Environment.GetEnvironmentVariable(entry.Key.ToString(), EnvironmentVariableTarget.User));
}
else
{
processEnvironment.Add(entry.Key.ToString(), entry.Value.ToString());
if (entry.Key.ToString().Equals("PATH"))
{
#if UNIX
processEnvironment.Add(entry.Key.ToString(), entry.Value.ToString());
#else
processEnvironment.Add(entry.Key.ToString(), entry.Value.ToString() + Path.PathSeparator + System.Environment.GetEnvironmentVariable(entry.Key.ToString(), EnvironmentVariableTarget.Machine) + Path.PathSeparator + System.Environment.GetEnvironmentVariable(entry.Key.ToString(), EnvironmentVariableTarget.User));
#endif
}
else
{
processEnvironment.Add(entry.Key.ToString(), entry.Value.ToString());
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class ResolvePathCommand : CoreCommandWithCredentialsBase
/// </summary>
[Parameter(Position = 0, ParameterSetName = "Path",
Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
[Parameter(Position = 0, ParameterSetName = "PathWithRelativeBase",
Mandatory = true, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)]
public string[] Path
{
get
Expand All @@ -40,6 +42,8 @@ public string[] Path
/// </summary>
[Parameter(ParameterSetName = "LiteralPath",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Parameter(ParameterSetName = "LiteralPathWithRelativeBase",
Mandatory = true, ValueFromPipeline = false, ValueFromPipelineByPropertyName = true)]
[Alias("PSPath", "LP")]
public string[] LiteralPath
{
Expand All @@ -59,7 +63,8 @@ public string[] LiteralPath
/// Gets or sets the value that determines if the resolved path should
/// be resolved to its relative version.
/// </summary>
[Parameter()]
[Parameter(ParameterSetName = "Path")]
[Parameter(ParameterSetName = "LiteralPath")]
public SwitchParameter Relative
{
get
Expand All @@ -75,6 +80,25 @@ public SwitchParameter Relative

private SwitchParameter _relative;

/// <summary>
/// Gets or sets the path the resolved relative path should be based off.
/// </summary>
[Parameter(Mandatory = true, ParameterSetName = "PathWithRelativeBase")]
[Parameter(Mandatory = true, ParameterSetName = "LiteralPathWithRelativeBase")]
public string RelativeBasePath
{
get
{
return _relativeBasePath;
}

set
{
_relative = true;
_relativeBasePath = value;
}
}

#endregion Parameters

#region parameter data
Expand All @@ -84,10 +108,68 @@ public SwitchParameter Relative
/// </summary>
private string[] _paths;

private PSDriveInfo _relativeDrive;
private string _relativeBasePath;

#endregion parameter data

#region Command code

/// <summary>
/// Finds the path and drive that should be used for relative path resolution
/// represents.
/// </summary>
protected override void BeginProcessing()
{
if (_relative)
{
if (!string.IsNullOrEmpty(RelativeBasePath))
{
try
{
_relativeBasePath = SessionState.Internal.Globber.GetProviderPath(RelativeBasePath, CmdletProviderContext, out _, out _relativeDrive);
}
catch (ProviderNotFoundException providerNotFound)
{
ThrowTerminatingError(
new ErrorRecord(
providerNotFound.ErrorRecord,
providerNotFound));
}
catch (DriveNotFoundException driveNotFound)
{
ThrowTerminatingError(
new ErrorRecord(
driveNotFound.ErrorRecord,
driveNotFound));
}
catch (ProviderInvocationException providerInvocation)
{
ThrowTerminatingError(
new ErrorRecord(
providerInvocation.ErrorRecord,
providerInvocation));
}
catch (NotSupportedException notSupported)
{
ThrowTerminatingError(
new ErrorRecord(notSupported, "ProviderIsNotNavigationCmdletProvider", ErrorCategory.InvalidArgument, RelativeBasePath));
}
catch (InvalidOperationException invalidOperation)
{
ThrowTerminatingError(
new ErrorRecord(invalidOperation, "InvalidHomeLocation", ErrorCategory.InvalidOperation, RelativeBasePath));
}

return;
}

_relativeDrive = SessionState.Path.CurrentLocation.Drive;
_relativeBasePath = SessionState.Path.CurrentLocation.ProviderPath;
return;
}
}

/// <summary>
/// Resolves the path containing glob characters to the PowerShell paths that it
/// represents.
Expand All @@ -109,10 +191,9 @@ protected override void ProcessRecord()
{
// When result path and base path is on different PSDrive
// (../)*path should not go beyond the root of base path
if (currentPath.Drive != SessionState.Path.CurrentLocation.Drive &&
SessionState.Path.CurrentLocation.Drive != null &&
!currentPath.ProviderPath.StartsWith(
SessionState.Path.CurrentLocation.Drive.Root, StringComparison.OrdinalIgnoreCase))
if (currentPath.Drive != _relativeDrive &&
_relativeDrive != null &&
!currentPath.ProviderPath.StartsWith(_relativeDrive.Root, StringComparison.OrdinalIgnoreCase))
{
WriteObject(currentPath.Path, enumerateCollection: false);
continue;
Expand All @@ -127,8 +208,7 @@ protected override void ProcessRecord()
}

baseCache = basePath;
string adjustedPath = SessionState.Path.NormalizeRelativePath(currentPath.Path,
SessionState.Path.CurrentLocation.ProviderPath);
string adjustedPath = SessionState.Path.NormalizeRelativePath(currentPath.Path, _relativeBasePath);

// Do not insert './' if result path is not relative
if (!adjustedPath.StartsWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;

namespace Microsoft.PowerShell.Commands
{
Expand All @@ -21,18 +22,20 @@ public class BasicHtmlWebResponseObject : WebResponseObject
/// <summary>
/// Initializes a new instance of the <see cref="BasicHtmlWebResponseObject"/> class.
/// </summary>
/// <param name="response"></param>
public BasicHtmlWebResponseObject(HttpResponseMessage response) : this(response, null) { }
/// <param name="response">The response.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public BasicHtmlWebResponseObject(HttpResponseMessage response, CancellationToken cancellationToken) : this(response, null, cancellationToken) { }

/// <summary>
/// Initializes a new instance of the <see cref="BasicHtmlWebResponseObject"/> class
/// with the specified <paramref name="contentStream"/>.
/// </summary>
/// <param name="response"></param>
/// <param name="contentStream"></param>
public BasicHtmlWebResponseObject(HttpResponseMessage response, Stream contentStream) : base(response, contentStream)
/// <param name="response">The response.</param>
/// <param name="contentStream">The content stream associated with the response.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public BasicHtmlWebResponseObject(HttpResponseMessage response, Stream contentStream, CancellationToken cancellationToken) : base(response, contentStream, cancellationToken)
{
InitializeContent();
InitializeContent(cancellationToken);
InitializeRawContent(response);
}

Expand Down Expand Up @@ -141,15 +144,16 @@ public WebCmdletElementCollection Images
/// <summary>
/// Reads the response content from the web response.
/// </summary>
protected void InitializeContent()
/// <param name="cancellationToken">The cancellation token.</param>
protected void InitializeContent(CancellationToken cancellationToken)
{
string contentType = ContentHelper.GetContentType(BaseResponse);
if (ContentHelper.IsText(contentType))
{
// Fill the Content buffer
string characterSet = WebResponseHelper.GetCharacterSet(BaseResponse);

Content = StreamHelper.DecodeStream(RawContentStream, characterSet, out Encoding encoding);
Content = StreamHelper.DecodeStream(RawContentStream, characterSet, out Encoding encoding, cancellationToken);
Encoding = encoding;
}
else
Expand Down
Loading