Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Add 'PSObject.Copy()' to 'substitute()' #5962

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- **json:** Serialize jsonpath return ([#5921](https://github.com/ScoopInstaller/Scoop/issues/5921))
- **scoop-search:** Catch error of parsing invalid manifest ([#5930](https://github.com/ScoopInstaller/Scoop/issues/5930))
- **autoupdate:** Copy `PSCustomObject`-type properties within `autoupdate` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934))
- **autoupdate:** Copy `PSCustomObject`-type properties within `substitute()` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934), [#5962](https://github.com/ScoopInstaller/Scoop/issues/5962))
- **system:** Fix argument passing to `Split-PathLikeEnvVar()` in deprecated `strip_path()` ([#5937](https://github.com/ScoopInstaller/Scoop/issues/5937))
- **scoop-cache:** Fix regression in 36026f18 ([#5944](https://github.com/ScoopInstaller/Scoop/issues/5944))
- **core:** Fix "Invoke-ExternalCommand" quoting rules ([#5945](https://github.com/ScoopInstaller/Scoop/issues/5945))
Expand Down
2 changes: 1 addition & 1 deletion lib/autoupdate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ function Update-ManifestProperty {
}
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
# Update other property (global)
$autoupdateProperty = $Manifest.autoupdate.$currentProperty.PSObject.Copy()
$autoupdateProperty = $Manifest.autoupdate.$currentProperty
$newValue = substitute $autoupdateProperty $Substitutions
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
# Make sure it's an array
Expand Down
6 changes: 3 additions & 3 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1250,8 +1250,8 @@ function Test-ScoopCoreOnHold() {
}

function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
$newentity = $entity
if ($null -ne $newentity) {
if ($null -ne $entity) {
$newentity = $entity.PSObject.Copy()
switch ($entity.GetType().Name) {
'String' {
$params.GetEnumerator() | ForEach-Object {
Expand All @@ -1263,7 +1263,7 @@ function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
}
}
'Object[]' {
$newentity = $entity | ForEach-Object { ,(substitute $_ $params $regexEscape) }
$newentity = $entity | ForEach-Object { , (substitute $_ $params $regexEscape) }
}
'PSCustomObject' {
$newentity.PSObject.Properties | ForEach-Object { $_.Value = substitute $_.Value $params $regexEscape }
Expand Down