Skip to content

Commit

Permalink
fix(core): Add 'PSObject.Copy()' to 'substitute()' (ScoopInstaller#5962)
Browse files Browse the repository at this point in the history
  • Loading branch information
niheaven authored May 13, 2024
1 parent a5bd229 commit 4dd2cfd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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

0 comments on commit 4dd2cfd

Please sign in to comment.